CocoaPods在Xcode 5.0.2下安装失败。

4
我已经被这个问题困扰了几个小时,但是仍然无法找到解决方案。我正在运行Mavericks,并安装了Xcode 5.0.2(它带有命令行工具)。
我的环境:
- 使用带有Ruby版本1.9.3p484的RVM - Xcode 5.0.2 - Mac OS 10.9.1 - Gem 2.2.0 - Bundler版本1.3.5
使用sudo gem install cocoapods输出:
kyles-mbp-2:fresh-driver-ios kylechronis$ sudo gem install cocoapods
     Building native extensions.  This could take a while...
     ERROR:  Error installing cocoapods:
     ERROR: Failed to build gem native extension.

    /Users/kylechronis/.rvm/rubies/ruby-1.9.3-p484/bin/ruby -rubygems    
    /Users/kylechronis/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/gems/1.9.1/gems/rake- 0.9.2.2/bin/rake RUBYARCHDIR=/Users/kylechronis/.rvm/rubies/ruby-1.9.3- p484/lib/ruby/gems/1.9.1/extensions/x86_64-darwin-13/1.9.1/xcodeproj-0.14.1 RUBYLIBDIR=/Users/kylechronis/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/gems/1.9.1/extensions/x86_64-darwin-13/1.9.1/xcodeproj-0.14.1

   /Users/kylechronis/.rvm/rubies/ruby-1.9.3-p484/bin/ruby extconf.rb
   checking for -std=c99 option to compiler... yes
   checking for CoreFoundation... no
   checking for main() in -lCoreFoundation... no
   CoreFoundation is needed to build the Xcodeproj C extension.
    *** 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.

这是否是因为找不到CoreFoundation,或者使用了不同版本的Ruby?非常感谢您的任何帮助或意见。
4个回答

19

安装新的Ruby版本对我很有帮助。 按照以下步骤进行:

rvm reinstall ruby-2.0.0-p247 --with-gcc=clang --verify-downloads 1
gem install xcodeproj
gem install cocoapods

我在一些旧的Github问题中找到了这个答案。


1
这对我来说是解决方法,尽管我将自己从1.9.3-p484回退到了1.9.3-p448。在这种情况下,似乎p484构建出了一些问题。 - ether_joe
这对我也有用,使用Xcode 5.0.2修复了它,在Ruby 1.9.2-p442上无法工作。 - frank
谢谢!完美地工作了!谢谢你,Artem! - Denis
如果您想在系统的任何目录中使用Cocoapods,请使用sudo gem install cocoapods。上述命令仅使其在安装时所在的同一目录中工作。请注意,这也符合Cocoapods网站上的安装说明 - abbood
也使用过2.1.1版本。 - Echelon

2
我遇到了这个:

http://cocoafactory.com/blog/2013/02/01/troubleshooting-cocoapods-installation/

这个:

http://railsapps.github.io/installrubyonrails-mac.html

我有点意识到我需要更新一些东西,因为我在1.9.3版本,我尝试更新到2.1.0版本。然后我意识到我不能通过rvm install ruby来更新。所以我做了sudo gem update --system,这个命令做了一些工作,然后我成功地运行了rvm install ruby,将其更新到了2.1.0版本。顺便重新安装了cocoa pods...现在pod setup已经给我设置好了Cocoadpods主库 :)

0

我遇到了相同的错误信息,花费了很多时间尝试上面和其他网站以及其他SO页面中的各种答案,包括:

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

以及

http://www.relaxdiego.com/2012/02/using-gcc-when-xcode-43-is-installed.html

以及其他许多

这些都没有任何区别

最终,我在我的iMac上创建了一个新用户,以查看是否可以在全新的安装中成功安装cocoapods,并且它非常完美地工作。我检查了所有各种版本的东西(ruby,gcc),发现新用户和旧用户的版本都是相同的。

然后我意识到,在我的~/.bashrc和~/.bash_profile文件中添加了一些额外的行,以帮助设置virtualenv,如下所示:

在.bashrc中:

export WORKON_HOME=$HOME/.virtualenvs 
export PROJECT_HOME=$HOME/Desktop/Programming
source /usr/local/bin/virtualenvwrapper.sh

并且在 .bash_profile 中:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" 

在注释掉这些行并加载 .bashrc 和 .bash_profile 后
$ source ~/.bashrc
$ source ~/.bash_profile

然后

$ sudo gem install cocoapods 

运行得非常顺利...

希望这对其他处于我之前绝望境地的人有所帮助


0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接