question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Apple Silicon (M1) troubleshooting guide (RN 0.64/0.65/0.66)

See original GitHub issue

Hey 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 on x86_64 or arm64 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:closed
  • Created 2 years ago
  • Reactions:84
  • Comments:84 (5 by maintainers)

github_iconTop GitHub Comments

17reactions
fkgozalicommented, Sep 23, 2021

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.

13reactions
mikehardycommented, Sep 1, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Build keeps failing on React Native with m1 & BigSur
I'm trying to build a project from scratch with React Native following the guideline. After struggling for hours for just to install and...
Read more >
Error if try build app on apple silicon, m1
have problem with my project when trying to build my app on M1 Pro Mac. If I want to build it on simulator,...
Read more >
User data & React Native + MobX project migration guide ...
Troubleshooting. CocoaPods on M1 (Apple Silicon) fails with ffi wrong architecture. If you run into errors related with ffi architecture (expecting arm64 but ......
Read more >
Announcing React Native 0.66
Better Support for Apple Silicon, Xcode 13, and iOS 15​ ... to make Xcode builds for iOS on Apple Silicon (M1) Mac machines...
Read more >
How to set up React Native on M1 Mac 2022 edition
Not all of the kinks of developing on the Apple Silicon Macs have been worked out yet, but with just a few small...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found