Error installing cocoapods [ mkmf.rb can’t find header files for ruby]

After buying RokcetWeb iOS from codecanyon, when I try to install cocoapods got this error:

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 -r ./siteconf20200425-1383-18dey0u.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

Solution:

It’s happened when your mac doesn’t found Ruby.framework library. First of all, make sure that you are using the latest MAC os and Xcode version. Then install the ruby library on the terminal where you are trying to install cocapod.

1. Check the version of Ruby installed on your Mac
Open terminal and type:
ruby -v

2. Install the Ruby Version Manager rvm
In terminal, curl -L https://get.rvm.io | bash -s stable

Once this command has finished running you may need to restart your terminal for rvm to be recognised.

3. Install the latest version of Ruby
rvm install ruby-[version]
In my case this was
rvm install ruby-2.3.0

This took a while to run as it had to install a lot of dependencies and asked for my permission a couple of times.

4. Set the latest version of Ruby as the one you want to use

You should now be running the latest version of Ruby.  You can check as before with the ruby -v command as in step 1. If you find that you’re not, you can set this manually.  In terminal type:
rvm use ruby-2.3.0

If you want to set this latest version of Ruby as the default version, in terminal type:
rvm –default use 2.3.0

One thought on “Error installing cocoapods [ mkmf.rb can’t find header files for ruby]

Leave a Reply