Cocoapods: Got error while trying pod install

Created on 18 Nov 2020  ·  27Comments  ·  Source: CocoaPods/CocoaPods

Command

/usr/local/bin/pod install

Report

  • What did you do?
    pod install

  • What did you expect to happen?
    Installing my pod's

  • What happened instead?
    Error. This is on my MacBook Pro with the new M1 processor, maybe it has something to do with that.

Stack

   CocoaPods : 1.10.0
        Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.arm64e-darwin20]
    RubyGems : 3.1.4
        Host : macOS 11.0.1 (20B29)
       Xcode : 12.2 (12B45b)
         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

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'KikiKickzLab' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for KikiKickzLab
  pod 'SwiftyJSON'

end

Error

LoadError - dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi_c.bundle, 0x0009): missing compatible arch in /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi_c.bundle - /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi_c.bundle
/Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi.rb:6:in `rescue in <top (required)>'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi.rb:3:in `<top (required)>'
/Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/Library/Ruby/Gems/2.6.0/gems/ethon-0.12.0/lib/ethon.rb:2:in `<top (required)>'
/Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/Library/Ruby/Gems/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus.rb:2:in `<top (required)>'
/Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/sources_manager.rb:74:in `cdn_url?'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/sources_manager.rb:36:in `create_source_with_url'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/sources_manager.rb:21:in `find_or_create_source_with_url'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:178:in `block in sources'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:177:in `map'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:177:in `sources'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:1073:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:1072:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:414:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:239:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:238:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:160:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/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'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'

Most helpful comment

sudo arch -x86_64 gem install ffi

Then

arch -x86_64 pod install

All 27 comments

This looks like an issue with ffi installation in your environment. There are many other issues related to this to look around for information.

At this time, CocoaPods is only a consumer of the ffi gem so there isn't much we can do to fix the specific issue you are getting. What we are trying to do is remove the dependency from ffi in a future release.

Ok, so until CocoaPods removes the ffi dependency I can't use it?

Or fix the ffi gem installation in your environment.

Fixed it by running the following command: arch -x86_64 pod install

Seeing the same on Mac mini with M1. I guess M1 arch is not supported?

After fresh installation of cocoapods on clean Mac mini:

# file /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi_c.bundle
/Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi_c.bundle: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit bundle x86_64] [arm64e:Mach-O 64-bit bundle arm64e]
/Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi_c.bundle (for architecture x86_64):    Mach-O 64-bit bundle x86_64
/Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi_c.bundle (for architecture arm64e):    Mach-O 64-bit bundle arm64e

no version for m1?

# uname -a
Darwin Maxims-Mac-mini.local 20.1.0 Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:10 PDT 2020; root:xnu-7195.50.7~2/RELEASE_ARM64_T8101 arm64

+1

sudo arch -x86_64 gem install ffi

Then

arch -x86_64 pod install

1.打开终端显示简介
2.勾选以Rosetta方式打开

  1. 运行 sudo gem install cocoapods (之前安装过就略过
  2. 运行 sudo gem install ffi
    5.最后pod install
    6.source 'https://github.com/CocoaPods/Specs.git' 有的网络不好需要先移除掉

this is true : https://stackoverflow.com/questions/64901180/running-cocoapods-on-apple-silicon-m1

We can definitely update title of this issue as compatibility with M1 chip. Same issues here happening on completely fresh and new MacBook Air with M1.

Guys, do you have any ideas to fix this problem, I am using MacBook air with M1 chip.
I can't use "pod search" or "pod update" command so far.

As suggested you need to duplicate terminal, run terminal through rosetta (aka x86) and use it there until CocoaPods add compatibility for ARM.

It seem little different with what I met. I can use "pod install", but not "pod search". I already make terminal run with rosetta, I don't know what happen.

sudo arch -x86_64 gem install ffi

Then

arch -x86_64 pod install

This worked for me

Here is the solution:
1- Go to your applications > utilities folder.
2- Right click and click "Get Info" on your terminal app
3- Check "Open Using Rosetta" option
4- Start your terminal app
5- sudo gem install cocoapods
6- sudo gem install ffi
7- pod install

worked on my end

This seems an issue with installing ffi gem on M1. At this time cocoapods depends on ffi gem but we are hoping to remove it in a future version which is the only thing that would circumvent this issue.

In the meantime please seek out alternatives on how to successfully install ffi gem within M1 environment.

I see people saying they can do this without Rosetta, but I can't reproduce that. It's very annoying.

sudo arch -x86_64 gem install ffi

Then

arch -x86_64 pod install

Can you clarify... does this mean you have to exclude arm64 and basically do everything after with x86_64?

Here is the solution:
1- Go to your applications > utilities folder.
2- Right click and click "Get Info" on your terminal app
3- Check "Open Using Rosetta" option
4- Start your terminal app
5- sudo gem install cocoapods
6- sudo gem install ffi
7- pod install

worked on my end

This is the right approach! I had to do some extra steps:
1- Uninstall cocoapods and ffi to begin with
2- Restart terminal after checking the option "Open Using Rosetta"
3- sudo xcode-select --switch /Applications/Xcode.app
then try -- pod install

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

This worked for me

Mac Mini M1 - worked too

It worked on Mac m1

All, it feels like I've gotten 100 emails about this fix/workaround of using arch -x86_64 (or using a Terminal in Rosetta mode). It's been posted a few times here already, and likewise on half a dozen other issues on the subject. It's probably futile to say this, but just keep I mind people are following these issues to wait for other developments.

以此在终端执行下面代码
sudo arch -x86_64 gem install ffi
arch -x86_64 pod install
如果依然有问题执行
arch -x86_64 pod update
我这里使用下面这一行解决的

Had the same issue, got it fixed after opening Terminal using Rosetta and after @handofthecode's answer.

Hello, You should install the latest version of CommandLineTools for Xcode to fix this issue.

@mhborujerdi saying it fixes itself with Xcode 12.4 CommandLineTools, or 12.5 beta3?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sonu5 picture sonu5  ·  3Comments

evermeer picture evermeer  ·  3Comments

pallaviMN picture pallaviMN  ·  3Comments

hmistry picture hmistry  ·  3Comments

Mingmingmew picture Mingmingmew  ·  3Comments