react-native: "Emulated x86_64" warning doesn't go away (M1 mac)

Description

Bootstrapped a new react-native project and got the following warning on pod install:

[!] Do not use "pod install" from inside Rosetta2 (x86_64 emulation on arm64).

[!]  - Emulated x86_64 is slower than native arm64

[!]  - May result in mixed architectures in rubygems (eg: ffi_c.bundle files may be x86_64 with an arm64 interpreter)

[!] Run "env /usr/bin/arch -arm64 /bin/bash --login" then try again.

I’m running on zsh (M1 macOS 12.1), so I ran the following but the warning remained:

env /usr/bin/arch -arm64 /bin/zsh --login
cd ios
pod install

Previously (on RN 0.66) I had run the following commands to install x86_64 ffi, which allowed me to successfully run pod install on M1. Other than that, I’m working on a fresh workstation.

arch -x86_64 gem install --user-install ffi -- --enable-libffi-alloc     

Version

0.67.1

Output of npx react-native info

System: OS: macOS 12.1 CPU: (10) arm64 Apple M1 Pro Memory: 103.91 MB / 32.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 16.13.2 - ~/.nvm/versions/node/v16.13.2/bin/node Yarn: 1.22.17 - ~/.nvm/versions/node/v16.13.2/bin/yarn npm: 8.1.2 - ~/.nvm/versions/node/v16.13.2/bin/npm Watchman: 2022.01.17.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.2 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3 Android SDK: Not Found IDEs: Android Studio: Not Found Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild Languages: Java: Not Found npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.67.1 => 0.67.1 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

npx react-native init foo --template react-native-template-typescript
cd foo/ios
pod install

Snack, code example, screenshot, or link to a repository

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 23
  • Comments: 25 (1 by maintainers)

Commits related to this issue

Most upvoted comments

What worked for me was installing cocoapods through brew, rather than gem.

sudo gem uninstall cocoapods
arch -arm64 brew install cocoapods

After that, you can navigate over to the ios/ directory in your project, and install away.

pod install

That should get you up and running on your M1 device of choice! Enjoy!

What worked for me was installing cocoapods through brew, rather than gem.

sudo gem uninstall cocoapods
arch -arm64 brew install cocoapods

I got a “pod command not found” error after installing cocoapods via brew.

I ran brew link --overwrite cocoapods to fix that. (The brew install process does actually tell you to do that, but I missed it!)

So I recently solved this. Ended up brew was running under Rosetta from an old installation causing a bunch of packages to also run under Rosetta it seems.

Anyway I ran brew config and there’s a line Rosetta 2: true usually your brew prefix will be /usr/local instead of /opt/homebrew which is the new brew prefix for using arm64.

I blew away the old brew (had to download the uninstall.sh package to run it with a path flag to point to the old brew install), reinstalled my packages, including nvm, chruby, pyenv etc. ( I wish I had saved a list of my current brew packages on the old install before I did this) and then installed cocoapods with brew. Now the error is gone.

This may have been my issue but if brew install cocoapods is not your fix it could be because your brew version is still running under Rosetta.

I started my project with a MBP early 2015. Then I changed my laptop to MB Air M1 last summer. A lot of struggling but I figured out to rebuild everything with Android & iOS. I have updated mac OS to Monterey. I feel like 7 months ago. I had to reinstall node, npm, react-native. I have the same message with the pod install. I don’t know what happened when upgrading the os but it seems that I lost a couple of stuff.

I ran the command mention by @richardgirges: arch -x86_64 gem install --user-install ffi -- --enable-libffi-alloc Still not working. Then I ran this command (which I did when I moved to my MB Air M1): ios/arch -x86_64 pod install The pods are installed and I can launch my project. Not sure that’s the best steps to do but I can work for now. Hope it would help you guys.

I did not have to do 99% of this.

1. rm -rf ~/Library/Developer/Xcode/DerivedData/
2. softwareupdate --install-rosetta
3. sudo arch -x86_64 gem install ffi
4. brew install node
5. brew install watchman
6. -- close terminal and reopen a new one
7. rm -rf node_modules && yarn install
8. cd ios; pod deintegrate; pod install
9. cd ..; yarn ios

+1 need help on that , thanks… for urgent project~