Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -199,7 +201,7 @@ def debug?
end

def type
@is_debug ? :debug : :release
return @is_debug ? :debug : :release
end
end

Expand Down
23 changes: 15 additions & 8 deletions packages/react-native/scripts/cocoapods/__tests__/utils-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
)
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/scripts/cocoapods/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unless is_release
next
end
Expand All @@ -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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unless is_release
next
end
Expand Down