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 @@ -197,6 +197,10 @@ def initialize(name, build_settings = {}, is_debug: false)
def debug?
return @is_debug
end

def type
@is_debug ? :debug : :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.

@cipolleschi I just noticed that I didn't explictly return here and I wanted to flag it in case you think it should be added for consistency

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Its fine! i personally prefer to have an explicit return, but Ruby automatically returns the last line of a function, and many people thinks that that's idiomatic Ruby.

I prefer not to do that, because not many people know Ruby to that degree of confidence, so being explicit makes the code more readable for everyone.

end
end

class TargetInstallationResultMock
Expand Down
35 changes: 26 additions & 9 deletions packages/react-native/scripts/cocoapods/__tests__/utils-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,24 @@ def test_SetGCCPreprocessorDefinitionForHermes_itSetsThePreprocessorForDebug
react_hermes_name = "React-hermes"
react_core_name = "React-Core"
hermes_engine_name = "hermes-engine"
react_hermes_debug_config = BuildConfigurationMock.new("Debug")
react_hermes_release_config = BuildConfigurationMock.new("Release")
react_core_debug_config = BuildConfigurationMock.new("Debug")
react_core_release_config = BuildConfigurationMock.new("Release")
hermes_engine_debug_config = BuildConfigurationMock.new("Debug")
hermes_engine_release_config = BuildConfigurationMock.new("Release")
react_hermes_target = TargetMock.new(react_hermes_name, [react_hermes_debug_config, react_hermes_release_config])
react_core_target = TargetMock.new(react_core_name, [react_core_debug_config, react_core_release_config])
hermes_engine_target = TargetMock.new(hermes_engine_name, [hermes_engine_debug_config, hermes_engine_release_config])

react_hermes_debug_config = BuildConfigurationMock.new("Debug", {}, is_debug: true)
react_hermes_release_config = BuildConfigurationMock.new("Release", {}, is_debug: false)
react_hermes_debug_config_rename = BuildConfigurationMock.new("Development", {}, is_debug: true)
react_hermes_release_config_rename = BuildConfigurationMock.new("Production", {}, is_debug: false)
react_hermes_target = TargetMock.new(react_hermes_name, [react_hermes_debug_config, react_hermes_release_config, react_hermes_debug_config_rename, react_hermes_release_config_rename])

react_core_debug_config = BuildConfigurationMock.new("Debug", {}, is_debug: true)
react_core_release_config = BuildConfigurationMock.new("Release", {}, is_debug: false)
react_core_debug_config_rename = BuildConfigurationMock.new("Development", {}, is_debug: true)
react_core_release_config_rename = BuildConfigurationMock.new("Production", {}, is_debug: false)
react_core_target = TargetMock.new(react_core_name, [react_core_debug_config, react_core_release_config, react_core_debug_config_rename, react_core_release_config_rename])

hermes_engine_debug_config = BuildConfigurationMock.new("Debug", {}, is_debug: true)
hermes_engine_release_config = BuildConfigurationMock.new("Release", {}, is_debug: false)
hermes_engine_debug_config_rename = BuildConfigurationMock.new("Development", {}, is_debug: true)
hermes_engine_release_config_rename = BuildConfigurationMock.new("Production", {}, is_debug: false)
hermes_engine_target = TargetMock.new(hermes_engine_name, [hermes_engine_debug_config, hermes_engine_release_config, hermes_engine_debug_config_rename, hermes_engine_release_config_rename])

installer = InstallerMock.new(
:pod_target_installation_results => {
Expand All @@ -211,10 +220,18 @@ def test_SetGCCPreprocessorDefinitionForHermes_itSetsThePreprocessorForDebug
expected_value = "$(inherited) HERMES_ENABLE_DEBUGGER=1"
assert_equal(expected_value, react_hermes_debug_config.build_settings[build_setting])
assert_nil(react_hermes_release_config.build_settings[build_setting])
assert_equal(expected_value, react_hermes_debug_config_rename.build_settings[build_setting])
assert_nil(react_hermes_release_config_rename.build_settings[build_setting])

assert_nil(react_core_debug_config.build_settings[build_setting])
assert_nil(react_core_release_config.build_settings[build_setting])
assert_nil(react_core_debug_config_rename.build_settings[build_setting])
assert_nil(react_core_release_config_rename.build_settings[build_setting])

assert_equal(expected_value, hermes_engine_debug_config.build_settings[build_setting])
assert_nil(hermes_engine_release_config.build_settings[build_setting])
assert_equal(expected_value, hermes_engine_debug_config_rename.build_settings[build_setting])
assert_nil(hermes_engine_release_config_rename.build_settings[build_setting])
end

# ================= #
Expand Down
12 changes: 6 additions & 6 deletions packages/react-native/scripts/cocoapods/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ def self.has_pod(installer, name)
end

def self.set_gcc_preprocessor_definition_for_React_hermes(installer)
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "HERMES_ENABLE_DEBUGGER=1", "React-hermes", "Debug")
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "HERMES_ENABLE_DEBUGGER=1", "React-jsinspector", "Debug")
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "HERMES_ENABLE_DEBUGGER=1", "hermes-engine", "Debug")
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "HERMES_ENABLE_DEBUGGER=1", "React-RuntimeHermes", "Debug")
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "HERMES_ENABLE_DEBUGGER=1", "React-hermes", :debug)
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "HERMES_ENABLE_DEBUGGER=1", "React-jsinspector", :debug)
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "HERMES_ENABLE_DEBUGGER=1", "hermes-engine", :debug)
self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "HERMES_ENABLE_DEBUGGER=1", "React-RuntimeHermes", :debug)
end

def self.turn_off_resource_bundle_react_core(installer)
Expand Down Expand Up @@ -193,11 +193,11 @@ def self.apply_xcode_15_patch(installer, xcodebuild_manager: Xcodebuild)

private

def self.add_build_settings_to_pod(installer, settings_name, settings_value, target_pod_name, configuration)
def self.add_build_settings_to_pod(installer, settings_name, settings_value, target_pod_name, configuration_type)
installer.target_installation_results.pod_target_installation_results.each do |pod_name, target_installation_result|
if pod_name.to_s == target_pod_name
target_installation_result.native_target.build_configurations.each do |config|
if configuration == nil || (configuration != nil && config.name.include?(configuration))
if configuration_type == nil || (configuration_type != nil && config.type == configuration_type)
config.build_settings[settings_name] ||= '$(inherited) '
config.build_settings[settings_name] << settings_value
end
Expand Down