How to run CocoaPods on Apple Silicon (M1)

224,333

Solution 1

EDIT: I recently disabled Rosetta, and Cocoapods runs just fine with the addition of the ffi gem.

For anyone else struggling with this issue, I just found a way to solve it. In addition to running terminal in Rosetta:

  1. Right-click on Terminal in Finder
  2. Get Info
  3. Open with Rosetta

I installed a gem that seems to be related to the symbol not found in the error:

sudo gem install ffi

After doing this, cocoapods runs as expected.

Solution 2

2022 July Update

If you can use Homebrew to manage cocoapods.

# Uninstall the local cocoapods gem
sudo gem uninstall cocoapods

# Reinstall cocoapods via Homebrew
brew install cocoapods

2021 Solution

# STEP 1: Install ffi
sudo arch -x86_64 gem install ffi

# STEP 2: Re-install dependencies
arch -x86_64 pod install

Additional Information

#1 For anyone seeing the arch: posix_spawnp: gem: Bad CPU type in executable error, you must first install Rosetta. Thanks, @Jack Dewhurst

#2 If you run pod commands pretty often, setting up an alias in .zshrc or .bash_profile might be handy. Thanks, @theMoonlitKnight for the suggestion.

alias pod='arch -x86_64 pod'

Solution 3

TL;DR:

  • Install your own version of Ruby with Homebrew / rbenv / RVM (e.g. brew install ruby)
  • Add it and the gems binaries to your PATH and make sure the new version is used with which ruby (should be /opt/homebrew/opt/ruby/bin/ruby instead of /usr/bin/ruby if installed with Homebrew)
  • Install CocoaPods with sudo gem install cocoapods (make sure ethon is at least version 0.13.0)
  • Run pod install

Detailed answer:

All answers suggesting using Rosetta / arch -x86_64 are workarounds and not quite solving the real issue that comes from the way RbConfig and the universal binaries work.

require 'rbconfig'

OSVERSION = RbConfig::CONFIG['host_os']
ARCH = RbConfig::CONFIG['arch']
HOSTCPU = RbConfig::CONFIG['host_cpu']
BUILDCPU = RbConfig::CONFIG['build_cpu']
TARGETCPU = RbConfig::CONFIG['target_cpu']

puts "OS: #{OSVERSION}"
puts "Arch: #{ARCH}"
puts "Host CPU: #{HOSTCPU}"
puts "Build CPU: #{BUILDCPU}"
puts "Target CPU: #{TARGETCPU}"

If you call ruby on a file containing this code with the universal binary shipped with macOS, you will get the following result on an M1 Mac:

OS: darwin20
Arch: universal-darwin20
Host CPU: x86_64
Build CPU: x86_64
Target CPU: universal

As you can see, RbConfig was compiled for a « universal » CPU but built with an x86 CPU, and the rbconfig.rb file that was generated (see /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin20/rbconfig.rb) consequently uses invalid information for the host CPU.

As ffi uses information from RbConfig (see https://github.com/ffi/ffi/blob/dfae59e293974efaa7b4d414e5116d7a2187a06e/lib/ffi/platform.rb#L61 and https://github.com/ffi/ffi/blob/e3f2cf9b82055709ddbeecbf77810f43438c4b64/spec/ffi/fixtures/compile.rb#L11), we end up with OP’s error message.

The solution is, therefore, to get a version of Ruby built specifically for arm64 by using either Homebrew, rbenv or RVM.

For Homebrew:

  • Execute brew install ruby
  • Add export PATH=/opt/homebrew/opt/ruby/bin:/opt/homebrew/lib/ruby/gems/3.0.0/bin:$PATH to your .zshrc (you can find your Homebrew installation directory with $(brew --prefix) if needed)
  • Execute source ~/.zshrc or restart your shell
  • Make sure you are using the correct ruby binary by executing which ruby (should be $(brew --prefix)/opt/ruby/bin/ruby)
  • Install CocoaPods with sudo gem install cocoapods
  • Make sure you are using the correct pod binary by executing which pod (should be $(brew --prefix)/lib/ruby/gems/3.0.0/bin/pod)
  • Make sure ethon is version 0.13.0 or more with gem info ethon, otherwise run sudo gem install ethon
  • Run pod install

Ruby won't come with future macOS versions by default

Moreover, it should be noted that ruby is still included in macOS only « for compatibility with legacy software », as evidenced by running irb -v, so this is probably a good opportunity to install your own version anyway:

WARNING: This version of ruby is included in macOS for compatibility with legacy software. In future versions of macOS the ruby runtime will not be available by default and may require you to install an additional package.

irb 1.0.0 (2018-12-18)

Sources:

Solution 4

To install completely cocoapods on Mac with M1 chip (Apple Silicon), please follow these steps:

  1. Duplicate the Terminal application in the Utilities folder.
  2. Right-click on the app and choose to Get Info.
  3. Rename the other version of the app as you like.
  4. Check the option "open with Rosetta".
  5. Install Cocoapods with the command "sudo gem install cocoapods"
  6. Type the command line "gem install ffi" to fix the ffi bundle problem. Now you can do a "pod install" without a problem.

Source : iPhoneSoft

Solution 5

Simplest way I found :

sudo gem uninstall cocoapods

brew install cocoapods

Share:
224,333

Related videos on Youtube

Jacobo Koenig
Author by

Jacobo Koenig

Updated on July 08, 2022

Comments

  • Jacobo Koenig
    Jacobo Koenig almost 2 years

    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?

    • Simon McLoughlin
      Simon McLoughlin almost 3 years
      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
  • Jacobo Koenig
    Jacobo Koenig over 3 years
    Thanks Medhi. Since this is just a paraphrasing of my own answer, I cannot mark it as accept it. If you find this format to be more legible, you can suggest an edit to the answer.
  • Medhi
    Medhi over 3 years
    Hi Jacobo, i figured that your answer were too quick and I didn't even notice the Rosetta part. Sorry, but it's not my call to decide which is best :)
  • Cliff Helsel
    Cliff Helsel over 3 years
    This appears to work for me also. First, enable Rosetta on Terminal, install the ffi gem as documented above, then you can disable Rosetta.
  • Praveen
    Praveen over 3 years
    I had the same error and followed the above method and pod got installed. I am using MacBook M1
  • danial dehvan
    danial dehvan over 3 years
    despite all of the above answers that didn't work for me, this one worked! thanks.
  • Guven
    Guven over 3 years
    @CliffHelsel What does this actually do? Install a separate version of ffi? If yes, which version is installed? If not, how does this actually help? Couldn't get it working yet, just trying to understand the details.
  • caffeinum
    caffeinum over 3 years
    This is underrated. Any of the previous comments didn't help me, and I only needed to run one demo.
  • Adro
    Adro about 3 years
    @Metropolis, does this mean everytime I'm gonna install new pods, I'll be using this command arch -x86_64 pod install?
  • Muhammad bin Yusrat
    Muhammad bin Yusrat about 3 years
    How did you manage to disable rosetta.. I don't see any way of doing it...
  • Jasper Blues
    Jasper Blues about 3 years
    IT WORKS !!!!!!!!!!!!! Make sure to use the system ruby. RVM installed ruby (2.7.0) didn't work.
  • SuperTully
    SuperTully about 3 years
    These commands worked for me, whereas the original answer did not. Thanks!
  • Nicolas Braun
    Nicolas Braun about 3 years
    These commands work fine but you have to use the system version of Ruby. This did not work when i used Ruby 2.7 via rbenv
  • gundrabur
    gundrabur about 3 years
    This finally worked for me on a Mac mini M1. I like to add: After step 6. you can switch off "open with Rosetta 2" on the Terminal app again.
  • Firanto
    Firanto about 3 years
    @MuhammadbinYusrat I think what he meant was unchecking the Open with Rosetta on the Terminal.
  • Endel Dreyer
    Endel Dreyer about 3 years
    I was having exactly the experience you describe here. Tried applying the patch for ethon locally, but same Segmentation fault error was happening. What seemed to work for me (after having ruby --version as arm64-darwin20) was installing an older version of cocoapods (1.5.2)
  • Shengchalover
    Shengchalover about 3 years
    Followed every step but was only able to make pods to install after manually installing the latest typhoeus/ethon gem from github (which already includes the patch in the latest commit as of March 28 3e87140...). thanks for diving deep into the issue!
  • Austin Jones
    Austin Jones about 3 years
    I tried this but get a missing compatible arch error
  • Hikeland
    Hikeland about 3 years
    This answer should be marked as the correct answer in 2021.
  • El Horrible
    El Horrible about 3 years
    ethon 0.13.0 is out. Thank you for your research.
  • Louis Lemasson
    Louis Lemasson about 3 years
    "arch -x86_64" is a hack to just get things working, so this should be the accepted answer. Works perfectly.
  • ThinkAndCode
    ThinkAndCode about 3 years
    will there be any issues if don't disable rosetta?
  • El Horrible
    El Horrible about 3 years
    @ValentinBriand I installed cocoapods using brew (/opt/homebrew/bin/pod) and it seems it all works (I am using ruby 3.0.1p64). I have ethon 0.12.0 on system ruby but that is not used.
  • jignesh.world
    jignesh.world about 3 years
    arch: posix_spawnp: gem: Bad CPU type in executable
  • ScottyBlades
    ScottyBlades almost 3 years
    I must be an idiot, because this didn't work for me.
  • Emre Önder
    Emre Önder almost 3 years
    I done the steps but which pod still gives me /usr/local/bin/pod path. Other steps are correct. How can I change pod location to ruby one?
  • Valentin Briand
    Valentin Briand almost 3 years
    @EmreÖnder do which ruby and which gem point to your Homebrew directory? If not, make sure that /opt/homebrew/opt/ruby/bin is before /usr/bin in your PATH
  • Emre Önder
    Emre Önder almost 3 years
    Yes which ruby and which gem shows me the correct directory. I uninstalled cocapods and reinstall it but didn't work. If I type $(brew --prefix)/lib/ruby/gems/3.0.0/bin/pod) install rather than pod install It is working. Somehow, cocapod seems usr/bin rather than ruby path
  • vilmoskörte
    vilmoskörte almost 3 years
    This works. Forget the "arch -x86_64" circumvention in the other answers.
  • Mihir Oza
    Mihir Oza almost 3 years
    "open using Rosetta" comes in general section. It’s for those who don’t know this option
  • Frankely Diaz
    Frankely Diaz almost 3 years
    Go for the detailed answer is worth the extra minutes! thank you
  • lee
    lee almost 3 years
    Thanks, this work for my. With my Xcode work space, also need to update Carthage script path to run success. Thanks again.
  • tontonCD
    tontonCD almost 3 years
    Works fine. I need to keep "open with Rosetta" for the Terminal before calling pod install (if not, fails) The next solution (with the -x86_64 option) seems fine too, I'll try it.
  • tontonCD
    tontonCD almost 3 years
    wonderful! and it works also with arch -x86_64 pod update. Note that I did sudo gem install ffi once before, don't know if it's important
  • tontonCD
    tontonCD almost 3 years
    I have this version, but I still need to prefix all commands with arch -x86_64
  • Harshit Jain
    Harshit Jain almost 3 years
    Great @tontonCD , also you don't need sudo gem install ffi command because you're already doing same with sudo arch -x86_64 gem install ffi
  • Ahmed Kamal
    Ahmed Kamal almost 3 years
    @tontonCD if you're coming from an older version, uninstalling and reinstalling CocoaPods might fix this for you. please confirm if you had the chance to do so.
  • tontonCD
    tontonCD almost 3 years
    No, sorry, my M1 is new, it's the first time I install cocoa pod. It suggests that uninstalling is not sufficient... but perhaps mandatory...
  • Smart Coder
    Smart Coder over 2 years
    I was having issue with React/RCTBridgeModule.h file not found.
  • LW001
    LW001 over 2 years
    Could you please link to the answer you're adding to instead of the user auspicious99? They have edited two answers to this question and it's not clear which one you meant to add to. You can copy the link to an answer using the "Share" button below it and edit your post to contain the URL of the answer.
  • username
    username over 2 years
    @LW001 I did the edit - makes sense! Thank you so much!
  • Adrian Mole
    Adrian Mole over 2 years
    You appear to have already posted an extremely similar (near identical) answer elsewhere. Please refrain from so doing; a comment linking to your earlier answer may be more appropriate in such cases.
  • Mahadhi Hassan Chowdhury
    Mahadhi Hassan Chowdhury over 2 years
    Not Working in MacMINI. Getting this error "arch: posix_spawnp: pod: Bad CPU type in executable"
  • bauerMusic
    bauerMusic over 2 years
    So until there's an ffi update, instead of pod install we need arch -x86_64 pod install every time?
  • Mike Portanova
    Mike Portanova over 2 years
    @EmreÖnder did you ever solve this? My M1 computer arrived today and can't get pod to point to the right ruby.
  • Anthony Sette
    Anthony Sette over 2 years
    Rocking the M1X and this is still an issue, thanks for the help!
  • Bryan Bryce
    Bryan Bryce over 2 years
    This is just a duplicate of other earlier answers. Opening with Rosetta isn't required
  • Kartik Watwani
    Kartik Watwani over 2 years
    @MikePortanova I can help you. This works like a charm on my new iMac. First, run brew --prefix. Let's say the result is mikes/path. Then the changes for you would be export PATH=mikes/path/opt/ruby/bin:mikes/path/lib/ruby/gems/3.0.0/‌​bin:$PATH. Now which ruby and which pod should return mikes/path/opt/ruby/bin/ruby and mikes/path/lib/ruby/gems/3.0.0/bin/pod respectively after you install ruby and cocoa pods as mentioned in the answer.
  • SmileBot
    SmileBot over 2 years
    Great answer! But which pod returns /opt/homebrew/bin/pod for me. It seems to run fine. How do I point to the correct pod binary?
  • Valentin Briand
    Valentin Briand over 2 years
    @smileBot I think it's fine since which pod is pointing to your homebrew directory. Also, /opt/homebrew/bin/pod is likely a symlink so check where it points to.
  • SmileBot
    SmileBot over 2 years
    @ValentinBriand Ok great. It is a symlink pointing to /opt/homebrew/Cellar/cocoapods/1.11.2_1/bin/pod.
  • theMoonlitKnight
    theMoonlitKnight over 2 years
    Put alias pod='arch -x86_64 pod' in .zshrc or .bash_profile to just type pod install
  • Ananthakrishna
    Ananthakrishna over 2 years
    @xinyang I used these methods but for a firebase project its not working? any idea
  • aheigins
    aheigins over 2 years
    incredible!! after 2-3 hours of searching this fixed it.. thank you.
  • Christian Gossain
    Christian Gossain over 2 years
    This really should be the accepted answer. It's not a workaround. Also note that if you installed cocoa pods before installing Homebrew, make sure to temporarily comment out the Homebrew path from your .zshrc file (or bash version), fully uninstall cocoa pods then add the Home-brew path back. Otherwise there terminal will use the non-Homebrew version of cocoa pods (at least that was my experience).
  • Albert James Teddy
    Albert James Teddy over 2 years
    Do not read only the TL;DR, read the "For Homebrew" list that explains each step, in particular how to set up the PATH correctly.
  • Jack Dewhurst
    Jack Dewhurst over 2 years
    For anyone seeing the arch: posix_spawnp: gem: Bad CPU type in executable error you must first install Rosetta.
  • TomV
    TomV over 2 years
    [!] Oh no, an error occurred. on Mac M1
  • TomV
    TomV over 2 years
    The other solutions didn't work. But this one did. Thanks!
  • Supto
    Supto over 2 years
    Proper solution
  • sergevm
    sergevm over 2 years
    Works fine! To have 'which pod' to show the proper version of CocoaPods, I had to restart my terminal. Followed the brew path.
  • CodeChanger
    CodeChanger over 2 years
    perfectly working great answer (y)
  • CoBrA2168
    CoBrA2168 over 2 years
    This should be the correct answer. Thank you for the detailed explanation. Worked fantastic on my 2021 MacBook Pro M1 Max.
  • TomV
    TomV over 2 years
    Only partially works: pod install works fine. pod update has this error: LoadError - dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/lib/ffi_c.bu‌​ndle, 0x0009): tried: '/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/lib/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/ffi_c.bundle' (no such file) - /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/lib/ffi_c.bundle /System/Library/Fr
  • Yakup DURMUS
    Yakup DURMUS over 2 years
    Work it ! Thanks so much. I am use M1 macbook
  • Sniady
    Sniady over 2 years
    I confirm, only brew helped.
  • qix
    qix over 2 years
    I used asdf as my ruby version manager and this works fine...as long as you remember to remove any CocoaPods install (sudo /usr/bin/gem uninstall cocoapods) you may have done earlier with the ancient system Ruby, or ! That placed the pod command in /usr/local/bin, which was picked up first in my PATH instead of the asdf shim.
  • Lucas Garcez
    Lucas Garcez over 2 years
    To set the Homebrew-installed Ruby to take priority over the system Ruby I need set if [ -d "/opt/homebrew/opt/ruby/bin" ]; then export PATH=/opt/homebrew/opt/ruby/bin:$PATH export PATH=`gem environment gemdir`/bin:$PATH fi on my ~/.zshrc. For the complete guide see mac.install.guide/ruby/13.html
  • Juan Fernandez Sosa
    Juan Fernandez Sosa over 2 years
    this works fine with my M1 chip
  • 1nstinct
    1nstinct over 2 years
    brew install ruby Running brew update --preinstall... ==> Auto-updated Homebrew! Updated 1 tap (homebrew/core). ==> Updated Formulae Updated 1 formula. Error: Cannot install under Rosetta 2 in ARM default prefix (/opt/homebrew)! To rerun under ARM use: arch -arm64 brew install ... To install under x86_64, install Homebrew into /usr/local.
  • SeanMC
    SeanMC over 2 years
    This works for me on several M1 Macs. Much prefer this over manually running Rosetta for every pod-install
  • achow
    achow over 2 years
    Excellent answer and worked for me. Wish this could be pinned to the top
  • dotslash
    dotslash over 2 years
    This works great. I also did brew install libffi for using some 3rd party libs with flutter. the gem shipped from macOS isn't cool.
  • Владислав Стариков
    Владислав Стариков over 2 years
    Thank you! Saved my day. This should be accepted answer.
  • Tautvydas
    Tautvydas over 2 years
    Second step gives me this: arch: Can't find pod in PATH
  • Kalamarico
    Kalamarico over 2 years
    Thanks a lot to explain the main reason for understand the problem @ValentinBriand The 16k reputation should be yours xDDD
  • mducc
    mducc about 2 years
    In my case. Just open .zshrc and put alias pod='arch -x86_64 pod' in the end of line
  • razvan
    razvan about 2 years
    @NicolasBraun how did you get it to work with rbenv?
  • n13
    n13 about 2 years
    Feb 2022 - this works. Lots of outdated answers here because native Apple Silicon only started working recently with CocoaPod. Kudos for updating this answer!
  • pravchuk
    pravchuk about 2 years
    You copied my answer and edited yours. That's not fair.
  • Volkov Maxim
    Volkov Maxim about 2 years
    "2022 Update" works on M1!
  • Amon C
    Amon C about 2 years
    If you get error to install cocoapods use "sudo gem install cocoapods "
  • Erhan Demirci
    Erhan Demirci about 2 years
    thanks.really helpful. saved my time
  • IamToobDude
    IamToobDude about 2 years
    Can someone explain what arch -x86_64 is? Just curious because this is the second time I've revisited this page due to firebase issues and it's also a year later and only the 2021 answer works for me despite the timeline.
  • Nguyễn Anh Tuấn
    Nguyễn Anh Tuấn about 2 years
    This solution works pretty well for me without the need of "Open terminal with Rosetta".
  • IamToobDude
    IamToobDude about 2 years
    How do I add the path for this part? " Make sure you are using the correct pod binary by executing which pod (should be $(brew --prefix)/lib/ruby/gems/3.0.0/bin/pod) "
  • NineToeNerd
    NineToeNerd about 2 years
    Installing cocoapods via brew doesn't work if you're trying to use cocoapods-keys. Installing ruby through homebrew worked for me (as in this answer: stackoverflow.com/a/66556339/3462536) -- See issue thread in cocoapods-keys here: github.com/orta/cocoapods-keys/issues/217
  • Soropromo
    Soropromo about 2 years
    God bless you..I spent 10 hours on this, it worked.
  • Cyber
    Cyber about 2 years
    Try not to use Terminal with Rosetta
  • Rashesh Bosamiya
    Rashesh Bosamiya about 2 years
    This worked for me! I'm using Mac mini M1 & macOS Monterey. I installed cocoa pods using brew. Thank you for this answer
  • Vikas chhabra
    Vikas chhabra about 2 years
    Did not worked.
  • Chutipong Roobklom
    Chutipong Roobklom almost 2 years
    Confirm this solution works for Monterey 12.3.1 (updated 2022-May)
  • sjmeverett
    sjmeverett almost 2 years
    For the PATH, I added export PATH="$PATH:`gem environment gemdir`/bin" to my ~/.profile
  • Zaporozhchenko Oleksandr
    Zaporozhchenko Oleksandr almost 2 years
    it will be installed, but not linked, if you try to link - error occure
  • gaurav5430
    gaurav5430 almost 2 years
    after installing cocoapods using homebrew, i get command not found on zsh