4

我在安装在单独分区上的 Yosemite DP 7 上安装 Cocoapods 时遇到问题。我已经尝试按照使用 Xcode 6 和 10.10 Yosemite 在 Cocoapods 上找到的说明进行操作,并且由于 Stack Overflow 链接上提出的相同解决方案而关闭了问题(https://github.com/CocoaPods/CocoaPods/issues/2219 )。

我继续收到以下错误:

Rasmuss-MacBook-Pro:~ rasmusth$ sudo gem install cocoapods
Building native extensions.  This could take a while...
ERROR:  Error installing cocoapods:
    ERROR: Failed to build gem native extension.

    "/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby" -rubygems /Library/Ruby/Gems/2.0.0/gems/rake-0.9.6/bin/rake RUBYARCHDIR=/Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/ext RUBYLIBDIR=/Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/ext
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/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
    --without-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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:549:in `block in try_compile'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:502:in `with_werror'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:549:in `try_compile'
    from extconf.rb:24:in `block in <main>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:895:in `block in checking_for'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:340:in `block (2 levels) in postpone'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:310:in `open'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:340:in `block in postpone'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:310:in `open'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:336:in `postpone'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:894:in `checking_for'
    from extconf.rb:23:in `<main>'
rake aborted!
Command failed with status (1): [/System/Library/Frameworks/Ruby.framework/...]
/Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/ext/xcodeproj/Rakefile:37:in `block in <top (required)>'
Tasks: TOP => default => ext
(See full trace by running task with --trace)


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/ext/xcodeproj/gem_make.out

我怀疑这可能与我将优胜美地放在一个单独的分区上这一事实有关,但除此之外我一无所知。

4

2 回答 2

10

我遇到了同样的问题。在按照与其他人相同的步骤进行大量头发拉后,以下工作有效。

  1. $ xcode-select --install(确认命令行工具已安装)

  2. 已安装 nvm stable(和自制软件): $ \curl -sSL https://get.rvm.io | bash -s 稳定

  3. 关闭/重新打开终端

  4. 安装 ruby​​ 2.1.2: $ rvm install 2.1

  5. 切换到它:$ rvm use 2.1

  6. 卸载/重新安装 xcodeproj 和 cocoapods

于 2014-09-04T22:38:35.993 回答
0

Xcode 6.0 GM 缺少 10.10 SDK,因此xcodeproj无法编译其中包含一些需要 10.10 SDK 的 C 代码的 gem。这将在未来得到解决。现在你可以像这样解决它:

  • 终端: sudo gem uninstall cocoapods xcodeproj
  • 下载 Xcode 6.1(现在是 Beta 2)
  • 启动它去设置 -> 位置 -> 命令行工具 -> 更改为 Xcode 6.1 Beta
  • 终端: sudo gem install cocoapods
  • 将您的命令行工具改回 GM(如果您想要/需要)

更多信息参见:https ://github.com/CocoaPods/CocoaPods/issues/2432

于 2014-09-16T12:59:11.963 回答