我试图将cocoapods安装到运行OSX 10.9.1(新Mavericks)的MacBook Pro上,键入gem install cocoapods后,我得到以下错误:

    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

当前回答

我也遇到过类似的错误,那是我第一次在macOS Catalina上安装CocoaPods。最后通过安装Xcode命令行工具来管理。在终端中输入以下命令。(截至目前,该文件约为248.3mb)

xcode-select --install

将出现一个对话框,要求您批准下载和安装。下载可能需要一段时间,这取决于你的网速。一旦安装成功。尝试在终端中使用以下命令再次安装CocoaPods。

sudo gem install cocoapods

一旦完成,使用以下命令确认安装是否成功

pod setup --verbose

其他回答

有时候问题是你的xcode工具版本太低了。如果您还没有尝试运行这些命令

sudo rm -rf /Library/Developer/CommandLineTools

xcode-select——安装

Sudo xcodebuild -许可接受

打开/图书馆/开发/ CommandLineTools /包/ macOS_SDK_headers_for_macOS_10.14.pkg

麦克·蒙特利12.5,按照这些步骤为我工作

1. sudo xcode-select --install
2. sudo xcode-select --reset

错误:错误安装cocoapods:错误:未能建立gem本地扩展

首先安装Ruby版本管理器rvm:

curl -L https://get.rvm.io | bash -s stable

然后使用

source ~/.rvm/scripts/rvm 

然后安装最新版本的ruby:

rvm install ruby-2.7.2

然后流这个(你的终端)输出。

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/nec/.zprofile 

然后使用

eval "$(/opt/homebrew/bin/brew shellenv)"

最后再次尝试安装cocoapods:

sudo gem install cocoapods

我也遇到过类似的错误,那是我第一次在macOS Catalina上安装CocoaPods。最后通过安装Xcode命令行工具来管理。在终端中输入以下命令。(截至目前,该文件约为248.3mb)

xcode-select --install

将出现一个对话框,要求您批准下载和安装。下载可能需要一段时间,这取决于你的网速。一旦安装成功。尝试在终端中使用以下命令再次安装CocoaPods。

sudo gem install cocoapods

一旦完成,使用以下命令确认安装是否成功

pod setup --verbose

问题出在Unity之外。您需要运行终端并输入以下命令:

Sudo gem install -n /usr/local/bin cocoapods . sh 舱设置

这帮了我大忙!