From c027f0a41fd53a457a425d84e2c1e0ab6b862173 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Tue, 9 May 2023 04:42:17 -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 Reviewed By: NickGerleman Differential Revision: D45523646 fbshipit-source-id: 228a7e0ae98ea262af4d58b7dc855f944ebed463 --- .../AppDelegate/React-RCTAppDelegate.podspec | 11 +++++++++++ .../scripts/cocoapods/__tests__/codegen_utils-test.rb | 4 +++- .../cocoapods/__tests__/new_architecture-test.rb | 5 +++++ .../react-native/scripts/cocoapods/codegen_utils.rb | 4 +++- .../scripts/cocoapods/new_architecture.rb | 4 ++++ 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec b/packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec index 79d042eeaf53f9..a98f3aea404347 100644 --- a/packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec +++ b/packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec @@ -76,8 +76,19 @@ 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" + + 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-Fabric" s.dependency "React-RCTFabric" s.dependency "React-graphics" 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 a67425df1c51cf..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,6 +137,7 @@ 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" }, @@ -144,6 +145,9 @@ def test_installModulesDependencies_whenNewArchEnabledAndNewArchAndNoSearchPaths { :dependency_name => "ReactCommon/turbomodule/bridging" }, { :dependency_name => "ReactCommon/turbomodule/core" }, { :dependency_name => "React-NativeModulesApple" }, + { :dependency_name => "Yoga" }, + { :dependency_name => "React-Fabric" }, + { :dependency_name => "React-graphics" }, { :dependency_name => "hermes-engine" } ]) end @@ -169,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 a1de1528cfb2e4..66aea069815917 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,9 @@ 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"] == nil || ENV["USE_HERMES"] == "1" spec.dependency "hermes-engine"