ERROR: Error installing cocoapods: ERROR: Failed to build gem native extension

后端 未结 23 1742
深忆病人
深忆病人 2020-12-04 19:06

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:

相关标签:
23条回答
  • 2020-12-04 19:13

    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.

    0 讨论(0)
  • 2020-12-04 19:16

    I got same problem and I just fixed with change my /usr/local/include folder to /usr/local/include_old

    0 讨论(0)
  • 2020-12-04 19:17

    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.

    0 讨论(0)
  • 2020-12-04 19:18

    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
    
    0 讨论(0)
  • 2020-12-04 19:18

    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

    0 讨论(0)
  • 2020-12-04 19:19

    Sometimes the issue is that your xcode tools version is too low. Try running these commands if you already have it

    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

    0 讨论(0)
提交回复
热议问题