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.
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
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
Error installing cocoapods: Failed to build gem native extension
I follow this steps to install Cocoapods. May be it useful for you.
- Open Terminal
gem install cocoapods
pod setup
Error when installing cocoapods
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
Related Topics
Restkit and Saving to Coredata as Nsmanagedobject
How to Check If Haptic Engine (Uifeedbackgenerator) Is Supported
Swift How to Modify Exif Info in Images Taken from Mobile Camera
How to Detect an iOS App Installed or Upgraded
Is There a Practical Way to Compress Nsdata
Custom Init of Uiviewcontroller from Storyboard
How to Mock Ajax Call with Nsurlprotocol
Alamofire No Such Module (Cocoapods)
Avcapturevideopreviewlayer Landscape Orientation
iOS Uicollectionview - Default Flow, Fill Rows from Right to Left
Are There Any Analogues of [Nsstring Stringwithformat:] for Nsattributedstring
How to Easily Support Light and Dark Mode with a Custom Color Used in My App
Obj-C Afnetworking 2.0 Post Request Does Not Work
What Is Correct Format of Bundle Identifier in iOS
External Framework File/File.H (Parse/Parse.H) File Not Found