Search code examples
swiftcocoapods

Cannot install Cocoapods, keep getting error


I have been trying to install cocoapods but I keep getting an error. I have tried the following commands and get the same result.

sudo gem install cocoapods    
sudo gem install -n /usr/local/bin cocoapods

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.6.0/gems/ffi-1.13.1/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf20200726-37338-rvqxhv.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/include/ruby.h

You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/ffi-1.13.1/gem_make.out

Solution

  • After a lot of searching I finally came across a solution that I believe works. If you are use Mac OS Catalina you need to use Brew.

    1. Open Terminal on your Mac.

    2. Now, run

      ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null

    3. Install cocoapods using brew

      brew install cocoapods

    cocoapods is ready to use now!