Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
46 changes: 46 additions & 0 deletions packages/react-native/scripts/cocoapods/__tests__/utils-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,52 @@ def test_excludeArchitectures_whenHermesEngineIsIncluded_excludeI386
assert_equal(pods_projects_mock.save_invocation_count, 1)
end

def test_excludeArchitectures_whenHermesEngineIsNotIncluded_preserveExistingValue
# Arrange
user_project_mock = prepare_empty_user_project_mock()
user_project_mock.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
pods_projects_mock = PodsProjectMock.new()
installer = InstallerMock.new(pods_projects_mock, [
AggregatedProjectMock.new(user_project_mock)
])

# Act
ReactNativePodsUtils.exclude_i386_architecture_while_using_hermes(installer)

# Assert
user_project_mock.build_configurations.each do |config|
assert_equal(config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"], "arm64")
end

assert_equal(user_project_mock.save_invocation_count, 1)
assert_equal(pods_projects_mock.save_invocation_count, 1)
end

def test_excludeArchitectures_whenHermesEngineIsIncluded_appendI386
# Arrange
user_project_mock = prepare_empty_user_project_mock()
user_project_mock.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
pods_projects_mock = PodsProjectMock.new([], {"hermes-engine" => {}})
installer = InstallerMock.new(pods_projects_mock, [
AggregatedProjectMock.new(user_project_mock)
])

# Act
ReactNativePodsUtils.exclude_i386_architecture_while_using_hermes(installer)

# Assert
user_project_mock.build_configurations.each do |config|
assert_equal(config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"], "arm64 i386")
end

assert_equal(user_project_mock.save_invocation_count, 1)
assert_equal(pods_projects_mock.save_invocation_count, 1)
end

# ================= #
# Test - Fix Config #
# ================= #
Expand Down
14 changes: 11 additions & 3 deletions packages/react-native/scripts/cocoapods/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,23 @@ def self.turn_off_resource_bundle_react_core(installer)
end

def self.exclude_i386_architecture_while_using_hermes(installer)
isUsingHermes = self.has_pod(installer, 'hermes-engine')
Comment thread
jpdriver marked this conversation as resolved.
Outdated
key = "EXCLUDED_ARCHS[sdk=iphonesimulator*]"

projects = self.extract_projects(installer)

projects.each do |project|
project.build_configurations.each do |config|
currentValue = config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] || ""
current_setting = config.build_settings[key] || ""

excludesI386 = current_setting.include?("i386")

unless currentValue.include?("i386")
if isUsingHermes and !excludesI386
Comment thread
jpdriver marked this conversation as resolved.
Outdated
# Hermes does not support `i386` architecture
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "#{currentValue} i386".strip
config.build_settings[key] = "#{current_setting} i386".strip
else
# leave EXCLUDED_ARCHS unchanged or set it to "" if it doesn't already exist
config.build_settings[key] = current_setting
Comment thread
jpdriver marked this conversation as resolved.
Outdated
end
end

Expand Down