ERROR: Error installing cocoapods: ERROR: Failed to build gem native extension
IosOsx MavericksCocoapodsIos Problem Overview
I am trying to install cocoapods to my MacBook Pro running with OSX 10.9.1 (new Mavericks) and after type gem install cocoapods
I get the following error:
Building native extensions. This could take a while...
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
"/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby" -rubygems /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.1.1/bin/rake RUBYARCHDIR=/Users/rangreenberg/gems/gems/xcodeproj-0.14.1/ext RUBYLIBDIR=/Users/rangreenberg/gems/gems/xcodeproj-0.14.1/ext
/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for -std=c99 option to compiler... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby
/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:491:in `block in try_compile'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:443:in `with_werror'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:491:in `try_compile'
from extconf.rb:24:in `block in <main>'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
from extconf.rb:23:in `<main>'
rake aborted!
Command failed with status (1): [/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/...]
Tasks: TOP => default => ext
(See full trace by running task with --trace)
Gem files will remain installed in /Users/rangreenberg/gems/gems/xcodeproj-0.14.1 for inspection.
Results logged to /Users/rangreenberg/gems/gems/xcodeproj-0.14.1/ext/xcodeproj/gem_make.out
Ios Solutions
Solution 1 - Ios
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 )
Solution 2 - Ios
First, check the version of Ruby you are using.
$ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin18]
$ which ruby
usr/bin/ruby
Now use Homebrew to install the latest Ruby.
$ brew install ruby
==> ruby
By default, binaries installed by gem will be placed into:
/usr/local/lib/ruby/gems/2.7.0/bin
You may want to add this to your PATH.
ruby is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have ruby first in your PATH run:
$ echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> /Users/xxx/.bash_profile
For compilers to find ruby you may need to set:
$ export LDFLAGS="-L/usr/local/opt/ruby/lib"
$ export CPPFLAGS="-I/usr/local/opt/ruby/include"
Follow the instructions to set PATH. Now you will go to see the installed Ruby. Make sure to replace the 'xxx' with your username.
$ echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> /Users/xxx/.bash_profile
$ echo 'export LDFLAGS="-L/usr/local/opt/ruby/lib"' >> ~/.bash_profile
$ echo 'export CPPFLAGS="-I/usr/local/opt/ruby/include"' >> ~/.bash_profile
$ source ~/.bash_profile
Finally, Make sure your PATH is in place.
$ ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin18]
$ which ruby
/usr/local/opt/ruby/bin/ruby
You're good to go! Make sure you install by specifying the save destination as follows.
$ sudo gem install -n /usr/local/bin cocoapods
Solution 3 - Ios
You need to install Xcode's developer tools. The easiest way to do this is through terminal (this question)
xcode-select --install
Solution 4 - Ios
if you're also seeing error: active developer path
.. does not exist
you may also have to do this
$ sudo xcode-select --reset
Solution 5 - Ios
If none of above works then follow these steps
- sudo xcode-select --switch /Library/Developer/CommandLineTools
- sudo gem install cocoapods
If you get error like this '
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory
.'
then go to step 3
- $ sudo gem install -n /usr/local/bin cocoapods
Solution 6 - Ios
brew reinstall ruby
Add the below to your path
export PATH="/usr/local/opt/ruby/bin:$PATH"
If needed add these flags.
export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include"
Solution 7 - Ios
Update your gem tool first. This might take a while
sudo gem update --system
Use this instead
sudo gem install -n /usr/local/bin cocoapods -v 1.8.4
Latest CocoaPods 1.10.0 won't work.
you can verify the version with
pod --version
Solution 8 - Ios
I fixed the problem by using ruby 2.0 (which is the preferred way on mavericks) or greater. In case you are using rvm just change to the correct ruby with:
rvm use ruby-2.0
After that gem install cocoapods
worked correctly. To be more specific, I was using:
OSX 10.9.2
ruby-2.0.0-p353
cocoapods-0.32.1
Solution 9 - Ios
This command saved my day
> sudo gem install -n /usr/local/bin cocoapods -v 1.8.4
To be confirmed check the pod version
> pod --version
Solution 10 - Ios
First as wrote "Kevin" try to run in terminal:
xcode-select --install
If it doesn't help you download tools manually from apple developer site:
It helped me.
Solution 11 - Ios
My way to solved:
First of all, i have new mac os 10.15.7 and Xcode
None of previous solutions worked for me too
I note that pods install in Library 2.6.0 and decided that it needs to be updated:
> step 1
\curl -sSL https://get.rvm.io | bash -s stable --ruby
Ok!
Then i checked version: 2.6.0 - Why? In last string after install ruby, i noticed:
- To start using RVM you need to run
source /Users/abazhanov/.rvm/scripts/rvm
in all your open shell windows, in rare cases you need to reopen all shell windows.
ok, let's do it:
> step 2
source /Users/abazhanov/.rvm/scripts/rvm
Then i checked version: 2.7.0 - its ok!
step 3
sudo gem install cocoapods
As a result: 34 gems installed
I understand that the new version of Pods simply did not install on the old version of Ruby
Solution 12 - Ios
Open Terminal
xcode-select --install
sudo xcodebuild -license accept
curl -L https://get.rvm.io | bash -s stable
Close and Reopen Terminal
rvm install ruby-2.6
sudo gem install cocoapods
pod install
After completing right click on project top-left on android studio then click on Flutter -> Open IOS Module in Xcode
Solution 13 - Ios
I also had the same problem. This is probably happening because your computer has older version of ruby. So you need to first update your ruby. Mine worked for ruby 2.6.3 version
You need to first open terminal and put this code
curl -L https://get.rvm.io | bash -s stable
Then put this command
rvm install ruby-2.6.3
This would install the ruby for you if it hasn' t been installed.After this just update the ruby to the new version
rvm use ruby-2.6.3
After this just make ruby 2.6.3 your default
rvm --default use 2.6.3
This would possibly fix your issue. You can now put the command
sudo gem install cocoapods
And the command
pod setup
Solution 14 - Ios
First install Homebrew if you don't have it: https://brew.sh/index_pt-br
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Second, install ruby if you don't have it: https://www.ruby-lang.org/pt/documentation/installation/
brew install ruby
You can also follow these steps: https://gist.github.com/monicao/d372716cdfbb7e9cf692
Then, close your terminal and reopen it again.
Always use sudo to install cocoapods:
sudo gem install cocoapods
Solution 15 - Ios
Sometimes the issue is that your xcode tools version is too low. Try running these commands if you already haven't
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
sudo xcodebuild -license accept
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
Solution 16 - Ios
After trying various things Tosin Sotannde's method work for me first run this
sudo gem update --system
then
sudo gem install -n /usr/local/bin cocoapods -v 1.8.4
Solution 17 - Ios
If you installed it through Brew
, you can solve it with a simple command.
brew update
brew upgrade
Solution 18 - Ios
I fix the problem by follow step:
1:rvm install 2.0.0
2:rvm list
- ruby-1.9.3-p545 [ x86_64 ] => ruby-2.0.0-p451 [ x86_64 ]
3:rvm 2.0.0 —default
4:pod update
Solution 19 - Ios
Alright,
I had the same issue. Tried to install pods to my project but never worked out. I updated Xcode, Updated Command Line tools, reinstalled cocoapods... almost everything.
Sitting on my ass , writing pod in terminal showed up a screen listing available commands.
I read all of them and noticed the command
pod setup
which does
+ setup Setup the CocoaPods environment
After this line of code, my problem was fixed.
I hope my solution help other people in trouble like me.
Solution 20 - Ios
try to install cocoapods using brew. i found it here Apple
Try
brew install cocoapods
it will get cocoapods installed without this error.
Solution 21 - Ios
I was having the same exact problem, although I had the latest version of the xcode command-line tools.
If you have homebrew installed, do brew install apple-gcc42
. This immediately solved it for me.
Solution 22 - Ios
I was getting this error and had to completely reinstall cocoapods to fix it. Finally worked. Maybe this solution suits for anyone else.
sudo rm -rf home_folder/.cocoapods/
After that, did again
pod setup
and installed my libraries from zero, and everything worked.
Hope it helps!
Solution 23 - Ios
I got same problem and I just fixed with change my /usr/local/include
folder to /usr/local/include_old
Solution 24 - Ios
I was facing quite a similar error, and it was my first time installing CocoaPods on macOS Catalina. Finally managed by installing Xcode Commandline Tools. Type in the following command into your Terminal. (As of this day, this file is around 248.3mb)
xcode-select --install
A dialog should appear asking you to approve the download and installation. It might take a while to download depending on your internet speed. Once the installation is successful. Attempt to install CocoaPods once more with the following command in Terminal.
sudo gem install cocoapods
Once complete use the following command to confirm if installation was successful
pod setup --verbose
Solution 25 - Ios
Worked for me in 2020 (Mac OS Catalina)
xcode-select --install
sudo gem install -n /usr/local/bin cocoapods
Solution 26 - Ios
I faced same issue on macOS Catalina
. Even though Installing with Homebrew
worked, I was just curious why gem install cocoapods
fails, even it is the preferred or mentioned method of installation in their official documentation.
I tried almost all solutions above and may be some other too, I found while googling the issue.
Finally today I deleted the Xcode 12.4, I have, and installed again, actually for some other reason. Just for curiosity, I tried gem install cocoapods
again, and now it got worked, and installed cocoapods
, the same way mentioned in the official documentation.
Solution 27 - Ios
You must use the command in Terminal for installing Command Line Tools:
xcode-select --install
If you receive the message as a result of "Can't install the software because it is not currently available from the Software Update server.", You must download manually Command Line Tools from Apple site.
Solution 28 - Ios
I had multiple environments in my configuration, which was causing problems as rvm was interfering with the installation. Once ruby 2.x was detected the install went fine.
For my environment I did the following:
- xcode-select --install
- rvm implode (Note - too drastic - you may not need to do this, I didn't have any use for the older ruby installations, I removed them via rvm uninstall
one-by-one and then used rvm implode - gem install cocoapods
This time the last command worked without any issues.
Solution 29 - Ios
The same initial issue occurred when attempting to setup GoogleMaps in a Flutter app after running pod install
on the iOS directory.
Running pod install
the following error appeared:
zsh: /usr/local/bin/pod: bad interpreter: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: no such file or directory
Next, after running sudo gem install cocoapods
that resulted in another error similar to that shown at ERROR: Error installing cocoapods: ERROR: Failed to build gem native extension.
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
kevin recommends installing Xcode Developer Tools running:
xcode-select --install
and while highlighting the need to install the tools, the system again produced the same error as before when running the pod install
command.
Refresing the tools by removing and reinstalling them became the next target. The tools are removed with the following command:
rm -rf /Library/Developer/CommandLineTools
And again installing the xcode developer tools using:
xcode-select --install
Then, sudo gem install cocoapods
and pod install
ran successfully.
Solution 30 - Ios
None of previous solutions worked for me...
My situation is a fresh clean install of macOS Catalina + XCODE;
It happen that I had to first run Xcode before install cocoa pods (in first run, Xcode setups machine with tools);
After that, cocoa pods worked fine.
Solution 31 - Ios
i had this issue when i tryed to install cocoapods by running the command "sudo gem install cocoapods", but i was able to install it with no problems using brew
Solution 32 - Ios
This should unshallow both the cask and the core repo.
brew tap homebrew/cask
followed by...
brew tap homebrew/core
Solution 33 - Ios
I have same issue, cocoapods was not installing and waste 3 to 4 hours to get solve this error and finally I got the solution,
step1: open the terminal and run "brew reinstall ruby" and terminal will guide you how to export the path step2: and then run "sudo gem install cocoapods"
Solution 34 - Ios
The problem is outside Unity. You need to run the terminal and enter this commands:
sudo gem install -n /usr/local/bin cocoapods
pod setup
This saved my day !
Solution 35 - Ios
1.Update Brew
brew update
2.Install Cocoapods
brew install cocoapods