Skip to content

Commit 42dde12

Browse files
grabboufacebook-github-bot
authored andcommitted
Exclude i386 from valid architectures when building with Hermes on iOS (#30592)
Summary: When building React Native application in Release mode for an iPhone Simulator _and_ targeting `armv7`, Xcode will build all architectures (due to `ONLY_ACTIVE_ARCH` set to `false`, unlike in Debug mode). As a result, Xcode will try building for `i386` (32-bit iPhone Simulator), which fails as we don’t build Hermes binaries for `i386`. Fix is to disable `i386`, since it is not supported by `Hermes` and certain `Folly` features. ## Changelog [IOS] [BREAKING] - `i386` architecture will be automatically disabled when Hermes is being used. This might be potentially breaking for your workflow if you target `armv7` devices, as you will no longer be able to test on the simulator. [IOS] [FEATURE] - Replace `flipper_post_install` with `react_native_post_install` hook. Will automatically detect if Flipper is enabled. Pull Request resolved: #30592 Test Plan: Run React Native application with Hermes enabled (or Flipper) in Release mode and it should work just fine. Reviewed By: appden Differential Revision: D25564738 Pulled By: TheSavior fbshipit-source-id: e786ab73fb0a77de5869cf9e5999726c7d29f1d4
1 parent e54ead6 commit 42dde12

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

scripts/react_native_pods.rb

+18-3
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ def use_flipper!(versions = {}, configurations: ['Debug'])
9898
pod 'FlipperKit/FlipperKitNetworkPlugin', versions['Flipper'], :configurations => configurations
9999
end
100100

101+
def has_pod(installer, name)
102+
installer.pods_project.pod_group(name) != nil
103+
end
104+
101105
# Post Install processing for Flipper
102106
def flipper_post_install(installer)
103107
installer.pods_project.targets.each do |target|
@@ -109,23 +113,34 @@ def flipper_post_install(installer)
109113
end
110114
end
111115

112-
def react_native_post_install(installer)
116+
def exclude_architectures(installer)
113117
projects = installer.aggregate_targets
114118
.map{ |t| t.user_project }
115119
.uniq{ |p| p.path }
116120
.push(installer.pods_project)
117121

118122
arm_value = `/usr/sbin/sysctl -n hw.optional.arm64 2>&1`.to_i
119123

124+
# Hermes does not support `i386` architecture
125+
excluded_archs_default = has_pod(installer, 'hermes-engine') ? "i386" : ""
126+
120127
projects.each do |project|
121128
project.build_configurations.each do |config|
122129
if arm_value == 1 then
123-
config.build_settings.delete("EXCLUDED_ARCHS[sdk=iphonesimulator*]")
130+
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = excluded_archs_default
124131
else
125-
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
132+
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64 " + excluded_archs_default
126133
end
127134
end
128135

129136
project.save()
130137
end
131138
end
139+
140+
def react_native_post_install(installer)
141+
if has_pod(installer, 'Flipper')
142+
flipper_post_install(installer)
143+
end
144+
145+
exclude_architectures(installer)
146+
end

template/ios/Podfile

-5
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,5 @@ target 'HelloWorld' do
2525

2626
post_install do |installer|
2727
react_native_post_install(installer)
28-
29-
# Enables Flipper.
30-
#
31-
# Disable the next line if you are not using Flipper.
32-
flipper_post_install(installer)
3328
end
3429
end

0 commit comments

Comments
 (0)