Installing cocoapods on macOS Mojave 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


Sources

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