React Native pod install failed on Apple Silicon (M1)
Asked Answered
G

14

13

I got my new Macbook Pro which has M1 chip.

I tried to run my react native project but stucked on pod install.

After that, I created an empty project and tried on that still getting the same error.

### Command

```
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/bin/pod install
```

### Report

* What did you do?

* What did you expect to happen?

* What happened instead?


### Stack

```
   CocoaPods : 1.10.1
        Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.arm64e-darwin20]
    RubyGems : 3.0.3
        Host : macOS 11.0.1 (20B29)
       Xcode : 12.4 (12D4e)
         Git : git version 2.24.3 (Apple Git-128)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : 
```

### Plugins

```
cocoapods-deintegrate : 1.0.4
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-trunk       : 1.5.0
cocoapods-try         : 1.2.0
```

### Podfile

```ruby
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '10.0'

target 'temp2' do
  config = use_native_modules!

  use_react_native!(:path => config["reactNativePath"])

  target 'temp2Tests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  use_flipper!
  post_install do |installer|
    flipper_post_install(installer)
  end
end

target 'temp2-tvOS' do
  # Pods for temp2-tvOS

  target 'temp2-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end
end
```

### Error

```
LoadError - dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle, 0x0009): missing compatible arch in /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle - /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi.rb:6:in `rescue in <top (required)>'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi.rb:3:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/ethon-0.12.0/lib/ethon.rb:2:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus.rb:2:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/sources_manager.rb:74:in `cdn_url?'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/sources_manager.rb:36:in `create_source_with_url'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/sources_manager.rb:21:in `find_or_create_source_with_url'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:178:in `block in sources'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:177:in `map'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:177:in `sources'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:1073:in `block in resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:1072:in `resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:414:in `analyze'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:239:in `block in resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:238:in `resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:160:in `install!'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/command/install.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/command.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/bin/pod:55:in `<top (required)>'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/bin/pod:23:in `load'
/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/bin/pod:23:in `<main>'
```

――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

[!] Oh no, an error occurred.

Search for existing GitHub issues similar to yours:
https://github.com/CocoaPods/CocoaPods/search?q=dlopen%28%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.14.2%2Flib%2Fffi_c.bundle%2C+0x0009%29%3A+missing+compatible+arch+in+%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.14.2%2Flib%2Fffi_c.bundle+-+%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.14.2%2Flib%2Fffi_c.bundle&type=Issues

If none exists, create a ticket, with the template displayed above, on:
https://github.com/CocoaPods/CocoaPods/issues/new

Be sure to first read the contributing guide for details on how to properly submit a ticket:
https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md

Don't forget to anonymize any private data!

Looking for related issues on cocoapods/cocoapods...
 - Couldn't determine repo type for URL: `https://cdn.cocoapods.org/`: Invalid ABI specified
   https://github.com/CocoaPods/CocoaPods/issues/10368 [open] [2 comments]
   a week ago

 - CocoaPods compatibility with Apple DTK (Apple Silicon)
   https://github.com/CocoaPods/CocoaPods/issues/9907 [open] [75 comments]
   15 hours ago

 - Firebase installation error on xcode 12 com m1 processor
   https://github.com/CocoaPods/CocoaPods/issues/10329 [closed] [4 comments]
   12 hours ago

and 3 more at:
https://github.com/cocoapods/cocoapods/search?q=dlopen%28%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.14.2%2Flib%2Fffi_c.bundle%2C%200x0009%29%3A%20missing%20compatible%20arch%20in%20%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.14.2%2Flib%2Fffi_c.bundle%20-%20%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.14.2%2Flib%2Fffi_c.bundle&type=Issues&utf8=✓

After I make research about this topic I found several solutions but still my problem is not solved.

I already tried to install

sudo gem install ffi

and then tried pod install again. Still getting same error.

After that according to my research some people said to use terminal with rosetta or the another way to rosetta,

sudo arch -x86_64 gem install ffi
arch -x86_64 pod install

with these Intel based installation try I'm getting below error:

Analyzing dependencies
Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
Fetching podspec for `Folly` from `../node_modules/react-native/third-party-podspecs/Folly.podspec`
Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`
[!] Couldn't determine repo type for URL: `https://cdn.cocoapods.org/`: Invalid ABI specified

Did somebody faced with this problem? What I'm doing wrong or what I need to do to run my project?

Gainsay answered 27/1, 2021 at 10:32 Comment(0)
G
2

I realized that homebrew installation messed up cocoapods.

Simply, I uninstalled homebrew and start from beginning. Then it worked.

Gainsay answered 31/1, 2021 at 18:25 Comment(0)
E
13

for homebrew users

step 1 brew install cocoapods step 2 sudo arch -x86_64 gem install ffi step 3 arch -x86_64 pod install

fixed my issue

Etude answered 27/5, 2021 at 8:30 Comment(3)
This answer saved my 2 days. This worked for me 10000% perfectly. Thank you very muchPooh
Does this mean .. I will need to use arch -x86_64 pod install every time i want to do pod install in the future?Hip
yes @AungMyintThein but there is another solution for this use rosetta terminalEtude
M
10

My problem with ffi resolved with just brew install cocoapods =)

Firstly I tried to install from bundler and there was a specific old version of cocoapods which didn't support m1 yet; then I used brew and now with the latest cocoapods it works fine

Moazami answered 27/5, 2021 at 13:38 Comment(1)
This should be the accepted answer, because it preserves the ability to use homebrew. I didn't try the accepted answer because I didn't want to completely scrap homebrew just for the sake of RN so I don't know if it works, but this did work for me.Tarpeia
N
5

My problem was installing cocoapods with gem (which most tutorials online will tell you). Try uninstalling cocoapods with the following command:

gem uninstall cocoapods

Then install it again using brew

brew install cocoapods

homebrew installed the arm64 version, while gem seems to default to something else.

Narrowminded answered 19/11, 2021 at 1:16 Comment(1)
Thank you, for me this is the correct way and the best!Valdovinos
M
3

This resource helped me: https://www.lopau.com/error-running-cocoapod-pod-install-on-big-sur-with-ffi/

Run sudo gem inst ffi -- --disable-system-libffi

Mucus answered 30/3, 2021 at 12:21 Comment(1)
This worked successfully for me while running pod update when upgrading react native .64 to .65Amatruda
G
2

I realized that homebrew installation messed up cocoapods.

Simply, I uninstalled homebrew and start from beginning. Then it worked.

Gainsay answered 31/1, 2021 at 18:25 Comment(0)
S
1

this worked for me: (M1 Pro)

arch -x86_64 sudo gem install cocoapods
arch -x86_64 pod repo update
arch -x86_64 pod install

sources: https://github.com/CocoaPods/CocoaPods/issues/10349

Sokul answered 1/2, 2022 at 5:20 Comment(0)
A
0

I faced the same issue on M1 chip MacBook. Finally did the below

In rosetta terminal :

-- sudo rm -rf ~/.cocoapods/repos

Inside iOS folder

pod install
Amylolysis answered 16/8, 2021 at 17:27 Comment(0)
B
0

the solution for me was to init the app like this

arch -x86_64 npx react-native init awsomeproject
Brooklynese answered 19/9, 2021 at 18:30 Comment(0)
W
0

Install the latest version of Xcode from App Store, and then run these two commands in the Terminal:

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
Wore answered 25/11, 2021 at 8:19 Comment(0)
S
0

In my case the problem was that CocoaPod flipper was out of date. The change in the pod file from

 use_flipper()!

to

use_flipper!({ 'Flipper' => '0.95.0', 'Flipper-Folly' => '2.6.7', 'Flipper-RSocket' => '1.4.3', 'Flipper-DoubleConversion' => '3.1.7', 'Flipper-Glog' => '0.3.9', 'Flipper-PeerTalk' => '0.0.4' })

helped me.

Siesta answered 30/3, 2022 at 10:19 Comment(0)
O
0

Mac M1 architecture is not directly compatible with Cocoapods. If you encounter issues when installing pods, you can solve it by running:

  • sudo arch -x86_64 gem install ffi

  • arch -x86_64 pod install

These commands install the ffi package, to load dynamically-linked libraries and let you run the pod install properly, and runs pod install with the proper architecture.

Originative answered 31/3, 2022 at 11:3 Comment(0)
E
0

For me, this command worked

arch -x86_64 pod install

Eventuality answered 11/9, 2022 at 9:22 Comment(0)
M
0

XCode ruined installation

npm ERR! Couldn't install Pods. Updating the Pods project and trying again...
npm ERR! Command `pod install` failed.
npm ERR! └─ Cause: /bin/bash -c 

So I reset XCode command-line tools by run

sudo xcode-select --reset

hope it helps someone too )

Mesa answered 25/1, 2024 at 23:28 Comment(0)
S
0

Before running pod install && bundle exec pod install in the ios folder, run npm install in the project root directory.

This creates a node_modules folder which the Bundler needs to install the corresponding Pod libraries.

Stultify answered 19/5, 2024 at 12:49 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.