Xcode 11 can not successfully install Cocoapods causes and solutions: mkmf.rb can not find header files for ruby at xxx

Error Messages

mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h

Here Insert Picture Description

I mainly bought a new macbook pro, XCode 11 installed, and then ran into this error installed Cocoapods, and never before encountered

Later, after a variety of search, solution ideas and methods are as follows:

Emphasis

In macOS 10.14the installation Xcode 11, also need to install theXcode command line tools

$ sudo xcode-select --install

Added a link to accept the certificate

$ sudo xcodebuild -license accept

This problem is mainly because Xcode 11 carries macOS 10.15 SDK, the SDK contains ruby ​​2.6 header files, but ruby ​​2.3 macOS 10.14 but not the file system, so you can verify the problem by following command

$ ruby -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"]'

This command macOS 10.14 on the system case to install Xcode 11 version will print out this path does not exist

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0

Then, Xcode 11 is mounted on macOS 10.14 SDK, in this path /Library/Developer/CommandLineTools/SDKs/MacOS10.14.sdk. But it's not necessary because the old header files installed contaminate the system directory. So we have to change, specify the appropriate SDK header files and ruby 2.3

$ sudo xcode-select --switch /Library/Developer/CommandLineTools

Then, we'll look at the ruby ​​correct path 2.3

$ ruby -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"]'

The output will be a normal path exists

/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0

So, now, gem installyou can normally use

Now it can be pleasant to install cocoapods

$ gem install cocoapods

After installation, check the next version

$ pod --version

Export

1.9.0

Ultimately successful installation of the various libraries ~~
Here Insert Picture Description

Note:
XCode SDK 11 used before if you want to change it back, use the command

$ sudo xcode-select --switch /Applications/Xcode.app

Where necessary, the following two environment variables introduced, to write ~ / .zshrc file in

export GEM_HOME=$HOME/.gem
export PATH=$GEM_HOME/bin:$PATH

Here Insert Picture Description

Published 345 original articles · won praise 130 · views 670 000 +

Guess you like

Origin blog.csdn.net/u013538542/article/details/104660924