diff --git a/packages/react-native/scripts/cocoapods/__tests__/utils-test.rb b/packages/react-native/scripts/cocoapods/__tests__/utils-test.rb index 445a2455e0a..3946f72e4dc 100644 --- a/packages/react-native/scripts/cocoapods/__tests__/utils-test.rb +++ b/packages/react-native/scripts/cocoapods/__tests__/utils-test.rb @@ -423,6 +423,40 @@ def test_turnOffResourceBundleReactCore_correctlyAppliesPatch assert_equal("YES", assets_release_config.build_settings["CODE_SIGNING_ALLOWED"]) end + def test_updateOSDeploymentTarget_updatesNativeAndResourceBundleTargets + minimum = Helpers::Constants.min_ios_version_supported + higher_version = (minimum.to_f + 1).to_s + native_target = TargetMock.new('ExamplePod', [ + BuildConfigurationMock.new('Debug', {'IPHONEOS_DEPLOYMENT_TARGET' => '9.0'}), + BuildConfigurationMock.new('Release', {'IPHONEOS_DEPLOYMENT_TARGET' => higher_version}), + ]) + resource_bundle = TargetMock.new('ExampleResources', [ + BuildConfigurationMock.new('Debug', {'IPHONEOS_DEPLOYMENT_TARGET' => '9.0'}), + BuildConfigurationMock.new('Release', {'IPHONEOS_DEPLOYMENT_TARGET' => '12.4'}), + ]) + other_resource_bundle = TargetMock.new('OtherResources', [ + BuildConfigurationMock.new('Debug'), + BuildConfigurationMock.new('Release', {'IPHONEOS_DEPLOYMENT_TARGET' => higher_version}), + ]) + installer = InstallerMock.new(pod_target_installation_results: { + 'ExamplePod' => TargetInstallationResultMock.new( + native_target, native_target, [resource_bundle, other_resource_bundle] + ), + }) + + ReactNativePodsUtils.updateOSDeploymentTarget(installer) + + [ + [native_target, [minimum, higher_version]], + [resource_bundle, [minimum, minimum]], + [other_resource_bundle, [minimum, higher_version]], + ].each do |target, expected_versions| + assert_equal(expected_versions, target.build_configurations.map do |config| + config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] + end, target.name) + end + end + # ================================= # # Test - Apply Mac Catalyst Patches # # ================================= # diff --git a/packages/react-native/scripts/cocoapods/utils.rb b/packages/react-native/scripts/cocoapods/utils.rb index 9a2326e38ca..13a5630b0b7 100644 --- a/packages/react-native/scripts/cocoapods/utils.rb +++ b/packages/react-native/scripts/cocoapods/utils.rb @@ -451,11 +451,14 @@ def self.update_search_paths(installer) def self.updateOSDeploymentTarget(installer) installer.target_installation_results.pod_target_installation_results .each do |pod_name, target_installation_result| - target_installation_result.native_target.build_configurations.each do |config| - old_iphone_deploy_target = config.build_settings["IPHONEOS_DEPLOYMENT_TARGET"] ? - config.build_settings["IPHONEOS_DEPLOYMENT_TARGET"] : - Helpers::Constants.min_ios_version_supported - config.build_settings["IPHONEOS_DEPLOYMENT_TARGET"] = [Helpers::Constants.min_ios_version_supported.to_f, old_iphone_deploy_target.to_f].max.to_s + targets = [target_installation_result.native_target] + target_installation_result.resource_bundle_targets + targets.each do |target| + target.build_configurations.each do |config| + old_iphone_deploy_target = config.build_settings["IPHONEOS_DEPLOYMENT_TARGET"] ? + config.build_settings["IPHONEOS_DEPLOYMENT_TARGET"] : + Helpers::Constants.min_ios_version_supported + config.build_settings["IPHONEOS_DEPLOYMENT_TARGET"] = [Helpers::Constants.min_ios_version_supported.to_f, old_iphone_deploy_target.to_f].max.to_s + end end end end