Skip to content

Commit fdcacd7

Browse files
grabboufacebook-github-bot
authored andcommitted
fix: building in release mode for simulator (#30543)
Summary: Fixes #29984 Right now, running a React Native application with Xcode 12 in Release mode on an iPhone Simulator will fail with something like below: > [some file path], building for iOS Simulator, but linking in object file built for iOS, file '[some file path]' for architecture arm64 The best explanation of this issue has been provided by alloy in #29984: > This issue has started coming up with Xcode 12 and support for the new ARM based Macs, as `arm64` now no longer can be assumed to _only_ be for iOS devices. This means Xcode 12 will now also build for `arm64` simulator SDKs and it has become ambiguous if an arch slice in a prebuilt binary is meant for a simulator or device. > > In any case, for now this means that you can configure your Xcode project to exclude `arm64` when building for any iOS simulator SDK. This PR implements aforementioned workaround. ## Changelog [FIX] [IOS] - Fix running React Native project with Xcode 12 in Release on iPhone Simulator Pull Request resolved: #30543 Test Plan: Switch your scheme to Release and run the app on simulator. Will complete w/o issues. Reviewed By: appden Differential Revision: D25537295 Pulled By: TheSavior fbshipit-source-id: 2dc05cb80e59f1d95d2a84ab55ed6a5b5446411c
1 parent 687ddf0 commit fdcacd7

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

scripts/react_native_pods.rb

+21
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,24 @@ def flipper_post_install(installer)
108108
end
109109
end
110110
end
111+
112+
def react_native_post_install(installer)
113+
projects = installer.aggregate_targets
114+
.map{ |t| t.user_project }
115+
.uniq{ |p| p.path }
116+
.push(installer.pods_project)
117+
118+
arm_value = `/usr/sbin/sysctl -n hw.optional.arm64 2>&1`.to_i
119+
120+
projects.each do |project|
121+
project.build_configurations.each do |config|
122+
if arm_value == 1 then
123+
config.build_settings.delete("EXCLUDED_ARCHS[sdk=iphonesimulator*]")
124+
else
125+
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
126+
end
127+
end
128+
129+
project.save()
130+
end
131+
end

template/ios/Podfile

+10-4
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@ target 'HelloWorld' do
2020
# Enables Flipper.
2121
#
2222
# Note that if you have use_frameworks! enabled, Flipper will not work and
23-
# you should disable these next few lines.
24-
use_flipper!
23+
# you should disable the next line.
24+
use_flipper!()
25+
2526
post_install do |installer|
26-
flipper_post_install(installer)
27+
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)
2733
end
28-
end
34+
end

0 commit comments

Comments
 (0)