Error: Error Installing Cocoapods: Error: Failed to Build Gem Native Extension

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 )

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

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 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

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

CocoaPods installation failed Failed to build gem native extension

Checkout this post stackoverflow. If it doesn't work, try sudo less installation, here's the link for that cocoapods sudo less installation

Error installing cocoapods: Failed to build gem native extension

I follow this steps to install Cocoapods. May be it useful for you.

  1. Open Terminal
  2. gem install cocoapods
  3. pod setup


Related Topics



Leave a reply



Submit