-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apple Silicon (M1) troubleshooting guide (RN 0.64/0.65/0.66) #31941
Comments
This comment has been minimized.
This comment has been minimized.
This is great! My app now builds. I have tried several fixes. Thanks and great work @kelset |
Yup, this solution works on M1's. |
...and it is so much tidier than an empty swift file and bridging header isn't it? Discovering the one stack overflow comment on one of the posts about this that held the clue about putting the swift path in first and having that pass testing was a very happy moment, I had a really hard time solving this one |
Please post text, enclosed in triple-backticks if possible, of the actual errors. For instance the first image you posted is incredibly difficult to read on mobile, and does not contain the actual error. So I'm not sure what is going on there. No Your second error about swift libraries not being found appears to related to the error that this exact https://stackoverflow.com/help/minimal-reproducible-example is critical here, but my |
@mikehardy you're right. I'll prepare a better representation of the problem shortly so you can have the full picture. |
the steps I take
am I supposed to have that I've never set up a react-native app on a macbook before, so no idea what's the right steps. Thank you. |
My script (make-demo.sh) was originally intended for a "How do I integrate react-native-firebase" demonstration so it requires you to have firebase project files (the two files it fails on - GoogleService-Info.plist, google-services.json) in order to work successfully. Using it for a "how do I get react-native to work on Apple Silicon" requires a slightly different script that removes the react-native-firebase parts. I've done that on a branch, you may have more success with this: https://github.com/mikehardy/rnfbdemo/blob/rn65demo/make-demo.sh - you should retry with that As an aside, it is basically always safe to run |
@mikehardy I got your script, and tried again. |
Quite odd, it appears that everything should be working and yet you are apparently suffering from exactly the error that the Podfile post_install library path tweak is supposed to fix. I can't explain it, sorry |
not very hopeful 😂 |
trial and error with adding empty swift file + bridging header approach documented elsewhere, with other swift items in the library path, on other machines perhaps. All pretty vague but it's really just methodical testing of one approach after another until you find something that works, then continued trial and error examining why that solution worked, with the goal to reduce it to it's simplest possible application (and ideally to something that may be done in a post_install hook which is what I thought I had accomplished :-), but clearly not. |
I couldnt build react-native stripe package because of these swift errors. After adding 'post_install' part, it resolved! Now I can build finally :)) Thanks for your efforts and sharing it! |
I can see in your paths that you have spaces in some of your folder names (..such as "working\ dir"). I was getting stuck with the same error, and found this to be the cause. A brand new project from react-native init wouldn't even work - I had to move to a new location without any spaces in any parent folders, and it fixed it. To test, I created a new folder with a space, ran init, and hit the error again - haven't yet been able to figure out the underlying reason. Edit: kshitej first spotted this above. Missed that. |
Yes you are right now it's working fine. |
In a mixed Intel/M1 team whoever builds the app last changes the ios project file in the setting for Is there a fix to that? This is done in the |
I've noticed the same @pke and I'm not aware of any activity in the area |
Hmmm guess we have to upgrade all team members to M1 then ;) It's possible all 10.000 devs at facebook already have M1 so they just don't care? ;) |
I'd be shocked if that were the case, as M1 causes build failures in react-native semi-frequently. |
if I'd have to guess, it's more likely because they rely on BUCK on everything internally - anyway I think that it's an interesting report that you are surfacing and I feel more and more folks will start hitting it... I'll start asking internally at MSFT to see if we've hit it yet |
Which version of react-native are you using? The only reference to react-native/scripts/react_native_pods.rb Lines 212 to 221 in 2a6a685
It doesn't look like it'd break or flip unless you're enabling/disabling Hermes regularly. |
@tido64 that's new. Guess we need to upgrade RN then. We are on 66.3 |
@kelset what is BUCK? I have seen it but only in Android builds |
@pke https://buck.build/ this is what I'm referring to. I would probably suggest to update to RN67 or even 68 and see if things change, maybe it will address that for you |
This comment was marked as resolved.
This comment was marked as resolved.
@krdc + @adilkhan2163 - spaces in project working directories has been problematic off and on for a while. I believe the CLI |
Small update for Android users on M1s with the New Architecture. This is a patch to make sure the Android builds are working fine on M1s without any workaround or patching of files from the user: Hopefully we'll land it on 0.68.1 so we don't need further intervention on the Android side of things. EDIT: Clarification |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
I am facing the same error, error computing sha-1, while triggering the build from jenkins,fastlane. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Hey folks - it's been quite some time that this issue has been open and over time the tooling in the ecosystem (from CocoaPods to NDK, etc) have all rolled out newer versions so that the problems of compatibility with Apple Silicon machines have been addressed; so this issue is not relevant anymore. Closing. |
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
...as described in facebookarchive/react-native-fbsdk#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
'spost_install
section (aka "stanza"):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
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 runpod install
, you should be aware that as of this typing VSCode Terminal runs under Rosetta 2, and yourpod install
will do things you do not want based on mis-diagnosing yourarch
asx86_64
(via Rosetta 2), resulting in undefined behavior and pod install / compile errors. See microsoft/vscode#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.
The text was updated successfully, but these errors were encountered: