I have looked through a lot of these questions and none seem to apply. I am trying to install cocoapods and run pod init in my xcode project. When I run sudo gem install cocoa podsI get right the end and see this:

Building native extensions. This could take a while...
ERROR:  Error installing cocoapods:
ERROR: Failed to build gem native extension.

current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -I /Library/Ruby/Site/2.3.0 -r ./siteconf20200314-453-8td9mi.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2 for inspection.

And of course when I run pod init inside my Xcode project I get:

-bash: pod: command not found

It looks like CocoaPods 1.9.0, the latest version as of this writing, depends on a newer version of Ruby than 2.3.7. But macOS Mojave only includes Ruby 2.3.7, so you have a few different options.

  • Upgrade to macOS Catalina and get Ruby 2.6.3
  • Use Ruby Version Manager to install a newer version of Ruby
  • Install an older version of CocoaPods
    sudo gem install cocoapods -v 1.8.4


Other people have trouble with CocoaPods 1.9.0 on Mojave. 1 2 3 4 5

Some people got it working by upgrading to Ruby 2.6 or newer. 1 2


I solved the issue with this


It will work for you, it did the trick for me

  • 1
    Welcome to Ask Different! While this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. Link-only answers can become invalid if the linked page changes or disappears. – Glorfindel Jul 21 '20 at 20:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .