From 03aba2b26ad3aef70e0184b4cdb10366904b2c60 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Fri, 5 May 2023 07:24:43 -0700 Subject: [PATCH] Fix podspec setup for 3rd parties when using dynamic linking (#37275) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37275 When enabling `USE_FRAMEWORKS=dynamic`, we need to explicitly defines all the dependencies used by the pods. This change add those missing dependencies. ## Changelog: [iOS][Added] - Add explicit dependencies for 3rd parties libraries Differential Revision: D45523646 fbshipit-source-id: c0cc261454663b2a54f02cd85839344131028fd5 --- .../AppDelegate/React-RCTAppDelegate.podspec | 11 +++++++++++ .../scripts/cocoapods/__tests__/codegen_utils-test.rb | 4 +++- .../cocoapods/__tests__/new_architecture-test.rb | 8 +++++++- .../react-native/scripts/cocoapods/codegen_utils.rb | 4 +++- .../scripts/cocoapods/new_architecture.rb | 10 ++++++++++ 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec b/packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec index 79d042eeaf53f9..4b48bbe32c10bf 100644 --- a/packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec +++ b/packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec @@ -76,6 +76,17 @@ Pod::Spec.new do |s| s.dependency "RCTRequired" s.dependency "RCTTypeSafety" s.dependency "ReactCommon/turbomodule/core" + s.dependency "React-RCTNetwork" + s.dependency "React-RCTImage" + s.dependency "React-NativeModulesApple" + s.dependency "React-CoreModules" + s.dependency "React-Fabric" + + if ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == "1" + s.dependency "React-hermes" + else + s.dependency "React-jsc" + end if is_new_arch_enabled s.dependency "React-RCTFabric" diff --git a/packages/react-native/scripts/cocoapods/__tests__/codegen_utils-test.rb b/packages/react-native/scripts/cocoapods/__tests__/codegen_utils-test.rb index f8646a53cb34af..da138e23b86950 100644 --- a/packages/react-native/scripts/cocoapods/__tests__/codegen_utils-test.rb +++ b/packages/react-native/scripts/cocoapods/__tests__/codegen_utils-test.rb @@ -544,6 +544,7 @@ def get_podspec_no_fabric_no_script [ "\"$(PODS_ROOT)/boost\"", "\"$(PODS_ROOT)/RCT-Folly\"", + "\"$(PODS_ROOT)/DoubleConversion\"", "\"${PODS_ROOT}/Headers/Public/React-Codegen/react/renderer/components\"", "\"$(PODS_ROOT)/Headers/Private/React-Fabric\"", "\"$(PODS_ROOT)/Headers/Private/React-RCTFabric\"", @@ -551,6 +552,7 @@ def get_podspec_no_fabric_no_script ].join(' ') }, 'dependencies': { + "DoubleConversion": [], "FBReactNativeSpec": [], "RCT-Folly": [], "RCTRequired": [], @@ -563,7 +565,7 @@ def get_podspec_no_fabric_no_script "ReactCommon/turbomodule/core": [], "hermes-engine": [], "React-NativeModulesApple": [], - "glog": [] + "glog": [], } } end diff --git a/packages/react-native/scripts/cocoapods/__tests__/new_architecture-test.rb b/packages/react-native/scripts/cocoapods/__tests__/new_architecture-test.rb index 36b28c13472dd0..c97349ed15df31 100644 --- a/packages/react-native/scripts/cocoapods/__tests__/new_architecture-test.rb +++ b/packages/react-native/scripts/cocoapods/__tests__/new_architecture-test.rb @@ -137,13 +137,18 @@ def test_installModulesDependencies_whenNewArchEnabledAndNewArchAndNoSearchPaths [ { :dependency_name => "React-Core" }, { :dependency_name => "RCT-Folly", "version"=>"2021.07.22.00" }, + { :dependency_name => "glog" }, { :dependency_name => "React-RCTFabric" }, { :dependency_name => "React-Codegen" }, { :dependency_name => "RCTRequired" }, { :dependency_name => "RCTTypeSafety" }, { :dependency_name => "ReactCommon/turbomodule/bridging" }, { :dependency_name => "ReactCommon/turbomodule/core" }, - { :dependency_name => "React-NativeModulesApple" } + { :dependency_name => "React-NativeModulesApple" }, + { :dependency_name => "Yoga" }, + { :dependency_name => "React-Fabric" }, + { :dependency_name => "React-graphics" }, + { :dependency_name => "hermes-engine" } ]) end @@ -168,6 +173,7 @@ def test_installModulesDependencies_whenNewArchDisabledAndSearchPathsAndCompiler [ { :dependency_name => "React-Core" }, { :dependency_name => "RCT-Folly", "version"=>"2021.07.22.00" }, + { :dependency_name => "glog" } ] ) end diff --git a/packages/react-native/scripts/cocoapods/codegen_utils.rb b/packages/react-native/scripts/cocoapods/codegen_utils.rb index a8bee70fdb6d08..c980f05762de45 100644 --- a/packages/react-native/scripts/cocoapods/codegen_utils.rb +++ b/packages/react-native/scripts/cocoapods/codegen_utils.rb @@ -80,6 +80,7 @@ def get_react_codegen_spec(package_json_file, folly_version: '2021.07.22.00', fa header_search_paths = [ "\"$(PODS_ROOT)/boost\"", "\"$(PODS_ROOT)/RCT-Folly\"", + "\"$(PODS_ROOT)/DoubleConversion\"", "\"${PODS_ROOT}/Headers/Public/React-Codegen/react/renderer/components\"", "\"$(PODS_ROOT)/Headers/Private/React-Fabric\"", "\"$(PODS_ROOT)/Headers/Private/React-RCTFabric\"", @@ -129,8 +130,9 @@ def get_react_codegen_spec(package_json_file, folly_version: '2021.07.22.00', fa "React-jsi": [], "ReactCommon/turbomodule/bridging": [], "ReactCommon/turbomodule/core": [], - "React-NativeModulesApple": [], + "React-NativeModulesApple": [], "glog": [], + "DoubleConversion": [], } } diff --git a/packages/react-native/scripts/cocoapods/new_architecture.rb b/packages/react-native/scripts/cocoapods/new_architecture.rb index 4b954bcd8848e1..dbe86312083f2b 100644 --- a/packages/react-native/scripts/cocoapods/new_architecture.rb +++ b/packages/react-native/scripts/cocoapods/new_architecture.rb @@ -108,6 +108,7 @@ def self.install_modules_dependencies(spec, new_arch_enabled, folly_version) spec.dependency "React-Core" spec.dependency "RCT-Folly", '2021.07.22.00' + spec.dependency "glog" if new_arch_enabled current_config["OTHER_CPLUSPLUSFLAGS"] = @@new_arch_cpp_flags @@ -119,6 +120,15 @@ def self.install_modules_dependencies(spec, new_arch_enabled, folly_version) spec.dependency "ReactCommon/turbomodule/bridging" spec.dependency "ReactCommon/turbomodule/core" spec.dependency "React-NativeModulesApple" + spec.dependency "Yoga" + spec.dependency "React-Fabric" + spec.dependency "React-graphics" + + if ENV["USE_HERMES"] == 0 + spec.dependency "jsi" + else + spec.dependency "hermes-engine" + end end spec.pod_target_xcconfig = current_config