460

I have a Flutter project that I'm trying to run on iOS. It runs normally on my Intel-based Mac, but on my new Apple Silicon-based M1 Mac it fails to install pods.

LoadError - dlsym(0x7f8926035eb0, Init_ffi_c): symbol not found - /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/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.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)>'
/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'
/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>'

Based on a Github workaround, I tried to run Terminal using rosetta, but the issue remains the same: https://github.com/CocoaPods/CocoaPods/issues/9907#issuecomment-655870749

Realising it's still early for Macs with Apple Silicon. Is there a way to make this work for the time being?

1
  • Was unable to get it working without rosetta following the accepted answer, on a new M1 mac mini. Once installed via rosetta, its probably still running in compatibility mode, even if rosetta is later turned off. The correct answer is Valentin Briand's answer below. A very outdated version of Ruby is installed on Macs by default. Whats needed is to install a newer ruby (easiest via homebrew), config terminal to use that version and then just install cocoapods as normal Jun 11, 2021 at 13:46

42 Answers 42

1
2
1

If you Are using M1 chip system then use-

go to application folder-

select terminal open with rosseta- then run cmd-

sudo arch -x86_64 gem install ffi

Then

arch -x86_64 pod install
2
  • This is just a duplicate of other earlier answers. Opening with Rosetta isn't required Nov 1, 2021 at 19:19
  • Did not worked. May 5, 2022 at 17:31
1

Click right and open get info menu Check "Open using rosetta"

sudo gem install cocoapods

sudo gem install ffi

sudo gem update --system // Update ruby

If it doesn't work:

Install a ruby manager, I preferred rvm

rvm install:

  • $brew install gnupg
  • gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
  • \curl -sSL https://get.rvm.io | bash

Don't forget to add bash profile:

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to path for scripting (to manage Ruby versions) export PATH="$GEM_HOME/bin:$PATH" [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session as a function

  • Check

$rvm -list

command if rvm is installed successfully

  • Install new ruby version:

$rvm install 3.1.2

  • Select default version:

$rvm --default use 3.1.2

Then restart the terminal and run $sudo gem install cocoapods

1
  • Tried 10 other suggestions. THIS ONE WORKS! Sep 6, 2022 at 16:11
0

I did get this problem after new dependencies (Firebase) where added to the repo. Was then able to do the sudo arch -x86_64 gem install ffi, but other problems remained after it.

My fix was: re-cloning the repo and running it again.

Setup: Xcode 12.4 Mac M1 react-native 63.4

0

the solution for me was to add arch -x86_64 at the begining of the create command

0

This is what worked for me, trying to build app on Mac M1

first go to your applications folder and

select terminal app -> get info -> select run with rosseta

// if you are trying to build the app through xcode Repeat the above steps for xcode app

Note: Make sure your terminal and code are closed while doing so.

Now run your terminal switch to your project_folder/ios

Run below-shown commands

sudo gem install cocoapods

sudo gem install ffi

sudo arch -x86_64 gem install ffi
0

All of the above solutions are valid, just wanted to post that with home brew and cocoapods supports native Apple Silicon chips you can run the command without prefixing arch -x86_64

so, sudo gem install ffi will do the job.

0

we can easily fix this problem

  1. Click on Finder
  2. go to applications
  3. right click on xcode
  4. click on get info
  5. checkmark the open using Rosetta enter image description here
0

As of Nov 2022. Did the following on a 2021 M1 iMac and it works.

# uninstall cocoapods
sudo gem uninstall cocoapods

# Optional; unshallow homebrew core
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow

# Install homebrew to right locations; from https://brew.sh/
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Add shortcuts as prompted at the end of running the above command
echo '# Set PATH, MANPATH, etc., for Homebrew.' >> $HOME/.bash_profile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> $HOME/.bash_profile
eval "$(/opt/homebrew/bin/brew shellenv)"

# Install cocoapods
brew install cocoapods

# Further, install Vim; taken from https://formulae.brew.sh/formula/vim
brew install vim
0

Currently, ARCHFLAGS can be used to create a univeral binary install of cocoapods with the system Ruby shipped by Apple.

sudo env ARCHFLAGS='-arch arm64 -arch arm64e -arch x86_64' \
  gem install cocoapods

## needed for compatibility with system Ruby currently shipping with Ventura 
sudo env ARCHFLAGS='-arch arm64 -arch arm64e -arch x86_64' \
  gem install activesupport -v 6.1.7.3

## verify that universal binaries were installed:
CHECK_DIR="/Library/Ruby"
find "$CHECK_DIR" -name "*.bundle" | xargs file

# /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-22/2.6.0/ffi-1.15.5/ffi_c.bundle: Mach-O universal binary with 3 architectures: [x86_64:Mach-O 64-bit bundle x86_64] [arm64:Mach-O 64-bit bundle arm64] [arm64e:Mach-O 64-bit bundle arm64e]
# /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-22/2.6.0/ffi-1.15.5/ffi_c.bundle (for architecture x86_64):  Mach-O 64-bit bundle x86_64
# /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-22/2.6.0/ffi-1.15.5/ffi_c.bundle (for architecture arm64):   Mach-O 64-bit bundle arm64
# /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-22/2.6.0/ffi-1.15.5/ffi_c.bundle (for architecture arm64e):  Mach-O 64-bit bundle arm64e
# /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/ext/ffi_c/ffi_c.bundle:                       Mach-O universal binary with 3 architectures: [x86_64:Mach-O 64-bit bundle x86_64] [arm64:Mach-O 64-bit bundle arm64] [arm64e:Mach-O 64-bit bundle arm64e]
# /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/ext/ffi_c/ffi_c.bundle (for architecture x86_64):    Mach-O 64-bit bundle x86_64
# /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/ext/ffi_c/ffi_c.bundle (for architecture arm64): Mach-O 64-bit bundle arm64
# /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/ext/ffi_c/ffi_c.bundle (for architecture arm64e):    Mach-O 64-bit bundle arm64e
# /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle:                             Mach-O universal binary with 3 architectures: [x86_64:Mach-O 64-bit bundle x86_64] [arm64:Mach-O 64-bit bundle arm64] [arm64e:Mach-O 64-bit bundle arm64e]
# /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle (for architecture x86_64):  Mach-O 64-bit bundle x86_64
# /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle (for architecture arm64):   Mach-O 64-bit bundle arm64
# /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle (for architecture arm64e):  Mach-O 64-bit bundle arm64e

Tested on both an Apple Intel mini and an Apple Silicon mini. Each had a clean macOS Ventura 13.4 install with Xcode 14.3.1 (14E300c) on the boot drive.

The Apple Intel mini can create a universal binary with multiple Instruction Set Architecture (ISA) slices. However, the Intel can only run and test the native x86_64. The Apple Silicon mini with Rosetta enabled can run|test all of the arm64, arm64e, and x86_64 ISA binary slices.

0

For an M1 Mac and Gem/Ruby issues, read this (October 2023):

(First of all you should use homebrew to install rbenv and gem, links below): https://formulae.brew.sh/formula/brew-gem https://formulae.brew.sh/formula/rbenv-bundler

Here we go:

  • Install ruby/gem version:
    • sudo rbenv install 3.1.4 [or another version that you want]
    • rbenv global 3.1.4 [or another version that you want]
  • confirm ruby version installed (and which is in use):
    • rbenv versions
    • which -a ruby
    • ruby -v (should match with version installed)
  • remove gem:
    • rm -rf ~/.gem/
  • Install gem using rbenv:
    • sudo rbenv exec gem install bundler
  • gem environment (to confirm your paths)

Note when running this you should use APP dir:

  • bundle install (Inside APP dir)
  • npm install && npm run pod-install
0

uinstall homebrew first

/bin/bash -c "$(curl -fsSL
 https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"

reinstall for arch 86_64

sudo arch -x86_64 /bin/bash -c "$(curl -fsSL
 https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

now run

brew config

you must get rosetta 2:true

also check

arch

you should get i86 if u get arm64, reinstall brew

then install ruby version 3.1.0 or above as they support mac os M1

brew install [email protected]

then u can use

gem install cocoapods
pod install

remember to uninstall previous ruby and cocoapods

you may have to run pod install multiple times as x86_64 is slower than arm64

-1

If you are on an older project that needs to be ported over don't forget to update the project.pbxproj files in your Runner.xcodeproj and Pods.xcodeproj.

The IPHONEOS_DEPLOYMENT_TARGET probably is still pointed towards 8.0

Update all occurrences as follows:

IPHONEOS_DEPLOYMENT_TARGET = 9.0;
1
2

Not the answer you're looking for? Browse other questions tagged or ask your own question.