Apple Silicon (M1) troubleshooting guide (RN 0.64/0.65/0.66)
See original GitHub issueHey folks 👋
This issue wants to help everyone working from an M1 powered machine successfully be able to build their RN apps.
The points below have been written by @mikehardy (and only lightly edited for readability), so huge props to him for his work on this problem space 👏👏
All testing is done with this script and variations on it https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh - so that testing is reproducible.
Main fix
For Apple Silicon to work at all you need to address a linker problem with react-native and Swift libraries.
You know you have this problem if you see something like
ld: warning: Could not find or use auto-linked library ‘swiftCoreFoundation’
…as described in https://github.com/facebookarchive/react-native-fbsdk/issues/755
Many people recommend adding an empty Swift file with a bridging header, but it’s not ideal: it is a manual thing that requires GUI manipulation in Xcode = hard to document, not automatic and it is only done for the side effect it has of changing up library paths.
This solution directly has the desired effect, added in your local Podfile
’s post_install
section (aka “stanza”):
installer.aggregate_targets.each do |aggregate_target|
aggregate_target.user_project.native_targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['LIBRARY_SEARCH_PATHS'] = ['$(SDKROOT)/usr/lib/swift', '$(inherited)']
end
end
aggregate_target.user_project.save
end
Hermes + iOS
For Apple Silicon to successfully use Hermes for iOS you should use react-native 0.65. It is maybe possible with react-native 0.64 but it requires the updated Hermes dependency used in react-native 0.65 (v0.8.1), and trying to qualify that on react-native 0.64 is not something generally supportable. Hermes + iOS + Apple Silicon? Please update to react-native 0.65.
3rd party packages PSA
Many React Native third party libraries, like the ones @mikehardy is involved in react-native-google-signin and react-native-fbsdk-next are not ready for Apple Silicon yet. They both need forward ports to wrap the updated breaking-change versions of the underlying native SDKs, and that’s work in need of your effort.
Check the issue section of those repositories that error out on M1s, there’s probably already an ongoing effort to add support - help out if you can.
Anecdotally, Mike says that
I currently check in my podfile to edit out those dependencies for my Apple Silicon colleagues and prohibit release builds there. The
arch
command is useful in these cases, you may use it either in package.json scripts or your Podfile to detect if you are onx86_64
orarm64
and behave programmatically (removing dependencies perhaps) as needed
VSCode Terminal issues
tl;dr: do not run install / compile commands from a Terminal in VS Code unless your VS Code is up to date
If you program using VSCode and use Terminal inside VSCode for commands, like run pod install
, you should be aware that as of this typing VSCode Terminal runs under Rosetta 2, and your pod install
will do things you do not want based on mis-diagnosing your arch
as x86_64
(via Rosetta 2), resulting in undefined behavior and pod install / compile errors. See https://github.com/microsoft/vscode/issues/116763 for more details.
[edited: vscode current versions work great on arm64, even if it’s a remote-ssh connection]
If none of the above helped you, and you can reproduce your issue consistently - even on a freshly init’d project, then post a comment below with how to repro so that this can be investigated further.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:84
- Comments:84 (5 by maintainers)
Top GitHub Comments
FYI, I and @mikehardy have been verifying v0.66.0-rc.* in M1 machine on Xcode 12.5.* and Xcode 13. So far, it seems like all M1 related issues have been resolved in 0.66 release candidates.
More good news - this library lookup ordering thing is solved on react-native now, and should be in 0.66.0 https://github.com/react-native-community/releases/issues/246#issuecomment-910406770 - really excited, I think 0.66 will work out of the box on all apple machines without any workarounds needed