diff --git a/scripts/cocoapods/__tests__/utils-test.rb b/scripts/cocoapods/__tests__/utils-test.rb index 0cd6757ebc9f5d..bef4b5f9fb33cd 100644 --- a/scripts/cocoapods/__tests__/utils-test.rb +++ b/scripts/cocoapods/__tests__/utils-test.rb @@ -369,6 +369,62 @@ def test_fixReactBridgingHeaderSearchPaths_correctlySetsTheHeaderSearchPathsForA end end + # ===================================== # + # Test - Apply Xcode14 React-Core patch # + # ===================================== # + + def test_turnOffResourceBundleReactCore_correctlyAppliesPatch + # Arrange + react_core_target = TargetMock.new('React-Core') + react_core_target_native_target = react_core_target + react_core_debug_config = prepare_Code_Signing_build_configuration("Debug", "YES") + react_core_release_config = prepare_Code_Signing_build_configuration("Release", "YES") + + hermes_engine_target = TargetMock.new('hermes-engine') + hermes_engine_target_native_target = hermes_engine_target + hermes_engine_debug_config = prepare_Code_Signing_build_configuration("Debug", "NO") + hermes_engine_release_config = prepare_Code_Signing_build_configuration("Release", "NO") + + assets_target = TargetMock.new('assets') + assets_target_native_target = assets_target + assets_debug_config = prepare_Code_Signing_build_configuration("Debug", "YES") + assets_release_config = prepare_Code_Signing_build_configuration("Release", "YES") + + installer = InstallerMock.new(pod_target_installation_results: { + 'React-Core': + TargetInstallationResultMock.new( + react_core_target, + react_core_target_native_target, + [TargetMock.new('React-Core',[react_core_debug_config, react_core_release_config])] + ), + 'hermes-engine': + TargetInstallationResultMock.new( + hermes_engine_target, + hermes_engine_target_native_target, + [TargetMock.new('hermes-engine',[hermes_engine_debug_config, hermes_engine_release_config])] + ), + 'assets': + TargetInstallationResultMock.new( + assets_target, + assets_target_native_target, + [TargetMock.new('assets',[assets_debug_config, assets_release_config])] + ), + }) + + # Act + ReactNativePodsUtils.turn_off_resource_bundle_react_core(installer) + + # Assert + # these must have changed + assert_equal(react_core_debug_config.build_settings["CODE_SIGNING_ALLOWED"], "NO") + assert_equal(react_core_release_config.build_settings["CODE_SIGNING_ALLOWED"], "NO") + # these needs to stay the same + assert_equal(hermes_engine_debug_config.build_settings["CODE_SIGNING_ALLOWED"], "NO") + assert_equal(hermes_engine_release_config.build_settings["CODE_SIGNING_ALLOWED"], "NO") + assert_equal(assets_debug_config.build_settings["CODE_SIGNING_ALLOWED"], "YES") + assert_equal(assets_release_config.build_settings["CODE_SIGNING_ALLOWED"], "YES") + end + # ================================= # # Test - Apply Mac Catalyst Patches # # ================================= # @@ -466,3 +522,9 @@ def prepare_target(name, product_type = nil) prepare_config("Release") ], product_type) end + +def prepare_Code_Signing_build_configuration(name, param) + return BuildConfigurationMock.new(name, { + "CODE_SIGNING_ALLOWED" => param + }) +end diff --git a/scripts/cocoapods/utils.rb b/scripts/cocoapods/utils.rb index 7b5cc32bb453c4..cb8d288fd020ce 100644 --- a/scripts/cocoapods/utils.rb +++ b/scripts/cocoapods/utils.rb @@ -39,6 +39,20 @@ def self.has_pod(installer, name) installer.pods_project.pod_group(name) != nil end + def self.turn_off_resource_bundle_react_core(installer) + # this is needed for Xcode 14, see more details here https://github.com/facebook/react-native/issues/34673 + # we should be able to remove this once CocoaPods catches up to it, see more details here https://github.com/CocoaPods/CocoaPods/issues/11402 + installer.target_installation_results.pod_target_installation_results.each do |pod_name, target_installation_result| + if pod_name.to_s == 'React-Core' + target_installation_result.resource_bundle_targets.each do |resource_bundle_target| + resource_bundle_target.build_configurations.each do |config| + config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO' + end + end + end + end + end + def self.exclude_i386_architecture_while_using_hermes(installer) projects = installer.aggregate_targets .map{ |t| t.user_project } diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index 34dc213326c5b6..ce41a8eae2ef7e 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -148,6 +148,8 @@ def use_flipper!(versions = {}, configurations: ['Debug']) # - react_native_path: path to React Native. # - mac_catalyst_enabled: whether we are running the Pod on a Mac Catalyst project or not. def react_native_post_install(installer, react_native_path = "../node_modules/react-native", mac_catalyst_enabled: false) + ReactNativePodsUtils.turn_off_resource_bundle_react_core(installer) + ReactNativePodsUtils.apply_mac_catalyst_patches(installer) if mac_catalyst_enabled if ReactNativePodsUtils.has_pod(installer, 'Flipper')