ERROR: Error installing cocoapods: ERROR: Failed to build gem native extension
Run following command
brew cleanup -d -v
Then run below command
brew install cocoapods
Note: If you see failed to link then run brew link cocoapods
If linking is getting failed then run
brew link --overwrite cocoapods
This is how it get solved for me
For someone who is having m1 chip system they need to run this via Rosetta
select Terminal and press cmd(⌘)+I and check the "Open using Rosetta" option. ( For m1 chip based mac )
install cocoapods failed on mac
Try this (Worked for me with OSX 10.10)
- Open Xcode 6
- Open Preferences
- Click the Locations tab
- Change the Command Line Tools version to Xcode 6.0
Uninstall cocoapods
$ sudo gem uninstall cocoapods
Install xcodeproj
$ sudo gem install xcodeproj
Install cocoapods
$ sudo gem install cocoapods
Run pod --version
to verify
Error installing cocoapods : Failed to build gem native extension
The problem is that you are trying to use the system ruby. Don’t. It doesn’t belong to you. If you have to say sudo
or you see System/Library/Frameworks/Ruby
in the output, you’re doing it wrong.
Install Xcode and/or the Xcode tools, install homebrew, use rbenv to install your own ruby, and use it. Then you can install the cocoapods gem and off you go.
Error installing CocoaPods - macOS BigSur
Well, today I was able to finally install Cocoapods successfully, but it was a weird process.
When learning people usually tell you to stay away from betas, and while I was in the stable AppStore-version of Xcode, I was running Big Sur B9; and that could have been the problem.
I completely uninstalled Xcode 12.0.1 and then downloaded from Apple Developer Xcode 12.2 beta. I then downloaded and installed the command line tools also for 12.2 beta, and ran again the cocoapods installation in Terminal… and voila!
After installing and running Xcode beta I was able to install and now works fine.
Maybe when BigSur becomes public this will be solved? Because not everyone needs or has to run Xcode beta versions.
Error installing cocoa pods on macOS Big Sur
This would be resolved by:
sudo gem install -n /usr/local/bin cocoapods -v 1.8.4
If you needed to install CocoaPods 1.10.0 +
you can use HomeBrew and use the command below in your command line:
brew install cocoapods
gem native extension error while installing cocoapods
Open Terminal
curl -L https://get.rvm.io | bash -s stable
Reopen Terminal
rvm install ruby-2.6
rvm use ruby-2.6.3
rvm --default use 2.6.3
From MahmoudKhaled's comment on
link
Errors when installing cocoapods with gem
The answer for this can be found here here although it is unrelated to this question. Below is a snippet of the answer which works best.
For Xcode 11 on macOS 10.14, this can happen even after installing Xcode and installing command-line tools and accepting the license with
sudo xcode-select --install
sudo xcodebuild -license accept
The issue is that Xcode 11 ships the macOS 10.15 SDK which includes headers for ruby2.6, but not for macOS 10.14's ruby2.3. You can verify that this is your problem by running
ruby -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"]'
which on macOS 10.14 with Xcode 11 prints the non-existent path
/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
However, Xcode 11 installs a macOS 10.14 SDK within /Library/Developer/CommandLineTools/SDKs/MacOS10.14.sdk
. It isn't necessary to pollute the system directories by installing the old header files as suggested in other answers. Instead, by selecting that SDK, the appropriate ruby2.3 headers will be found:
sudo xcode-select --switch /Library/Developer/CommandLineTools
ruby -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"]'
This should now correctly print
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0
Likewise, gem install
should work while that SDK is selected.
To switch back to using the current Xcode 11 SDK, use
sudo xcode-select --switch /Applications/Xcode.app
Related Topics
Ruby on Rails 4 - Simple_Form Multiple Select Input
Rmagick - How to Find Out the Pixel Dimension of an Image
Installing Ruby-2.1.2: Cannot Load Such File -- Openssl (Loaderror)
Ruby: Array Contained in Array, Any Order
How to Correctly Install Rvm in Docker
Problem Using Openstruct with Erb
How to Specify the Location of the Chromedriver Binary
Rails: Methods Shared by Multiple Controllers
If(!X) VS If(X==False) in Ruby
Mailchimp API Not Replacing Mc:Edit Content Sections (Using Ruby Library)
Rails ( Set_No_Cache Method) Cannot Disable Browser Caching in Safari and Opera
Ruby Variable Name with Double Underscores
Activerecord Connection Warning. (Database Connections Will Not Be Closed Automatically)
How to Remove Non-Printable/Invisible Characters in Ruby