错误:安装cocoapods错误:错误:无法构buildgem本机扩展

我想安装cocoapods到我的macbook pro运行OSX 10.9.1(新的小牛)和types的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 

任何帮助将是伟大的。 提前致谢。

您需要安装Xcode的开发人员工具。 最简单的方法是通过terminal( 这个问题 )

 xcode-select --install 

我通过使用ruby2.0(这是在小牛的首选方式)或更大的问题解决了这个问题。 如果您正在使用rvm,只需更改为正确的ruby:

 rvm use ruby-2.0 

之后, gem install cocoapods工作正常。 更具体地说,我正在使用:

 OSX 10.9.2 ruby-2.0.0-p353 cocoapods-0.32.1 

首先写“凯文”尝试在terminal运行:

 xcode-select --install 

如果它不能帮助你从苹果开发者网站手动下载工具:

它帮助了我。

我通过以下步骤解决问题:

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 – 默认

4:荚更新

虽然我有最新版本的xcode命令行工具,但我遇到了同样的问题。

如果你已经安装了自制软件, brew install apple-gcc42 。 这立即解决了我的。

好的,

我遇到过同样的问题。 试图安装豆荚到我的项目,但从来没有解决。 我更新了Xcode,更新了命令行工具,重新安装了cocoapods …几乎所有东西。

坐在我的屁股上,写在terminal上的荚显示出一个列出可用命令的屏幕。

我读了所有这些,并注意到命令

 pod setup 

哪个呢

 + setup Setup the CocoaPods environment 

在这行代码之后,我的问题就解决了。

我希望我的解决scheme能帮助像我这样的麻烦的其他人。

我在configuration中有多个环境,这是由于rvm干扰安装而导致的问题。 一旦ruby2.x被发现安装进展良好。

对于我的环境,我做了以下几点:1. xcode-select –install 2. rvm implode(注意 – 太激烈了 – 你可能不需要这样做,我没有任何用于旧的ruby安装,我删除它们通过rvm一个一个的卸载,然后使用rvm implode 3. gem install cocoapods

这一次最后的命令没有任何问题。

我得到这个错误,不得不彻底重新安装cocoapods来解决它。 终于工作了。 也许这个解决scheme适合其他人。

 sudo rm -rf home_folder/.cocoapods/ 

之后,再次

 pod setup 

并从零安装我的库,一切工作。

希望能帮助到你!

您必须使用terminal中的命令安装命令行工具:

 xcode-select --install 

如果由于“无法安装软件,因为软件更新服务器当前不可用”而收到消息,则必须从Apple站点手动下载命令行工具。