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 6a7d5f7cb8b..c5cadd975d5 100644 --- a/packages/react-native/scripts/cocoapods/__tests__/new_architecture-test.rb +++ b/packages/react-native/scripts/cocoapods/__tests__/new_architecture-test.rb @@ -524,16 +524,20 @@ def prepare_installer_for_cpp_flags(xcconfigs, build_configs) end pod_target_installation_results_map = {} + user_build_configuration_map = {} build_configs.each do |name, build_configs| pod_target_installation_results_map[name.to_s] = prepare_pod_target_installation_results_mock( name.to_s, build_configs ) + build_configs.each do |config| + user_build_configuration_map[config.name] = config + end end return InstallerMock.new( PodsProjectMock.new, [ - AggregatedProjectMock.new(:xcconfigs => xcconfigs_map, :base_path => "a/path/") + AggregatedProjectMock.new(:xcconfigs => xcconfigs_map, :base_path => "a/path/", :user_build_configurations => user_build_configuration_map) ], :pod_target_installation_results => pod_target_installation_results_map ) diff --git a/packages/react-native/scripts/cocoapods/__tests__/test_utils/InstallerMock.rb b/packages/react-native/scripts/cocoapods/__tests__/test_utils/InstallerMock.rb index c06cb592e0a..318c349cacf 100644 --- a/packages/react-native/scripts/cocoapods/__tests__/test_utils/InstallerMock.rb +++ b/packages/react-native/scripts/cocoapods/__tests__/test_utils/InstallerMock.rb @@ -96,13 +96,15 @@ def save() class AggregatedProjectMock attr_reader :user_project attr_reader :xcconfigs + attr_reader :user_build_configurations @base_path - def initialize(user_project = UserProjectMock.new, xcconfigs: {}, base_path: "") + def initialize(user_project = UserProjectMock.new, xcconfigs: {}, base_path: "", user_build_configurations: {}) @user_project = user_project @xcconfigs = xcconfigs @base_path = base_path + @user_build_configurations = user_build_configurations end def xcconfig_path(config_name) @@ -199,7 +201,7 @@ def debug? end def type - @is_debug ? :debug : :release + return @is_debug ? :debug : :release end end diff --git a/packages/react-native/scripts/cocoapods/__tests__/utils-test.rb b/packages/react-native/scripts/cocoapods/__tests__/utils-test.rb index 821a702bcad..28b01500840 100644 --- a/packages/react-native/scripts/cocoapods/__tests__/utils-test.rb +++ b/packages/react-native/scripts/cocoapods/__tests__/utils-test.rb @@ -1153,19 +1153,21 @@ def test_add_flag_to_map_with_inheritance_whenUsedWithArrayAttributes def test_add_ndebug_flag_to_pods_in_release # Arrange xcconfig = XCConfigMock.new("Config") - default_debug_config = BuildConfigurationMock.new("Debug") - default_release_config = BuildConfigurationMock.new("Release") - custom_debug_config1 = BuildConfigurationMock.new("CustomDebug") - custom_debug_config2 = BuildConfigurationMock.new("Custom") - custom_release_config1 = BuildConfigurationMock.new("CustomRelease") - custom_release_config2 = BuildConfigurationMock.new("Production") + default_debug_config = BuildConfigurationMock.new("Debug", {}, is_debug: true) + default_release_config = BuildConfigurationMock.new("Release", {}, is_debug: false) + custom_debug_config1 = BuildConfigurationMock.new("CustomDebug", {}, is_debug: true) + custom_debug_config2 = BuildConfigurationMock.new("Custom", {}, is_debug: true) + custom_release_config1 = BuildConfigurationMock.new("CustomRelease", {}, is_debug: false) + custom_release_config2 = BuildConfigurationMock.new("Production", {}, is_debug: false) + custom_release_config3 = BuildConfigurationMock.new("Main", {}, is_debug: false) installer = prepare_installer_for_cpp_flags( [ xcconfig ], { "Default" => [ default_debug_config, default_release_config ], "Custom1" => [ custom_debug_config1, custom_release_config1 ], - "Custom2" => [ custom_debug_config2, custom_release_config2 ] + "Custom2" => [ custom_debug_config2, custom_release_config2 ], + "Custom3" => [ custom_release_config3 ], } ) # Act @@ -1178,6 +1180,7 @@ def test_add_ndebug_flag_to_pods_in_release assert_equal("$(inherited) -DNDEBUG", custom_release_config1.build_settings["OTHER_CPLUSPLUSFLAGS"]) assert_equal(nil, custom_debug_config2.build_settings["OTHER_CPLUSPLUSFLAGS"]) assert_equal("$(inherited) -DNDEBUG", custom_release_config2.build_settings["OTHER_CPLUSPLUSFLAGS"]) + assert_equal("$(inherited) -DNDEBUG", custom_release_config3.build_settings["OTHER_CPLUSPLUSFLAGS"]) end end @@ -1234,16 +1237,20 @@ def prepare_installer_for_cpp_flags(xcconfigs, build_configs) end pod_target_installation_results_map = {} + user_build_configuration_map = {} build_configs.each do |name, build_configs| pod_target_installation_results_map[name.to_s] = prepare_pod_target_installation_results_mock( name.to_s, build_configs ) + build_configs.each do |config| + user_build_configuration_map[config.name] = config + end end return InstallerMock.new( PodsProjectMock.new, [ - AggregatedProjectMock.new(:xcconfigs => xcconfigs_map, :base_path => "a/path/") + AggregatedProjectMock.new(:xcconfigs => xcconfigs_map, :base_path => "a/path/", :user_build_configurations => user_build_configuration_map) ], :pod_target_installation_results => pod_target_installation_results_map ) diff --git a/packages/react-native/scripts/cocoapods/utils.rb b/packages/react-native/scripts/cocoapods/utils.rb index 4ce64600cb1..9cf9eeac260 100644 --- a/packages/react-native/scripts/cocoapods/utils.rb +++ b/packages/react-native/scripts/cocoapods/utils.rb @@ -664,7 +664,7 @@ def self.add_ndebug_flag_to_pods_in_release(installer) installer.aggregate_targets.each do |aggregate_target| aggregate_target.xcconfigs.each do |config_name, config_file| - is_release = config_name.downcase.include?("release") || config_name.downcase.include?("production") + is_release = aggregate_target.user_build_configurations[config_name] == :release unless is_release next end @@ -678,7 +678,7 @@ def self.add_ndebug_flag_to_pods_in_release(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| - is_release = config.name.downcase.include?("release") || config.name.downcase.include?("production") + is_release = config.type == :release unless is_release next end