xcode 无法上班 CocoaPods 和 Yosemite

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25165016/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:20:34  来源:igfitidea点击:

Can't get to work CocoaPods and Yosemite

rubyxcoderubygemsxcode6cocoapods

提问by user3241911

I already tried this steps:

我已经尝试过以下步骤:

  1. Open Xcode 6 Open Preferences
  2. Click the Locations tab
  3. Change the Command Line Tools version to Xcode 6.0
  4. Uninstall cocoapods
  5. a. $sudo gem uninstall cocoapods Install xcodeproj
  6. a. $ sudo gem install
  7. xcodeproj Install cocoapods
  8. a. $ sudo gem install cocoapods
  9. Run pod --version to verify that it worked
  1. 打开 Xcode 6 打开首选项
  2. 单击位置选项卡
  3. 将命令行工具版本更改为 Xcode 6.0
  4. 卸载 cocoapods
  5. 一种。$sudo gem 卸载 cocoapods 安装 xcodeproj
  6. 一种。$ sudo gem 安装
  7. xcodeproj 安装 cocoapods
  8. 一种。$ sudo gem 安装 cocoapods
  9. 运行 pod --version 以验证它是否有效

But I'm still gettings this when I do pod install or pod --version:

但是当我执行 pod install 或 pod --version 时,我仍然得到这个:

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- xcodeproj/prebuilt/universal.x86_64-darwin14-2.0.0/xcodeproj_ext (LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/lib/xcodeproj/ext.rb:6:in `rescue in <top (required)>'
    from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/lib/xcodeproj/ext.rb:3:in `<top (required)>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/lib/xcodeproj.rb:30:in `<top (required)>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/lib/cocoapods.rb:2:in `<top (required)>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/bin/pod:32:in `<top (required)>'
    from /usr/bin/pod:23:in `load'
    from /usr/bin/pod:23:in `<main>'

回答by user3241911

In case someone else got the same issue, I did this to fix my issue:

如果其他人遇到同样的问题,我这样做是为了解决我的问题:

  1. Update Gems

    sudo gem update --system

  2. Uninstalled xcodeproj

    sudo gem uninstall xcodeproj

  3. Make sure to select All versions

  4. Uninstalled Cocoapods

    sudo gem uninstall cocoapods

  5. Install xcodeproj

    sudo gem install xcodeproj

  6. Install cocoapods

    sudo gem install cocoapods

  7. Run

    pod --version to test.

  1. 更新宝石

    sudo gem update --system

  2. 已卸载的 xcodeproj

    sudo gem uninstall xcodeproj

  3. 确保选择所有版本

  4. 卸载的 Cocoapods

    sudo gem uninstall cocoapods

  5. 安装 xcodeproj

    sudo gem install xcodeproj

  6. 安装 cocoapods

    sudo gem install cocoapods

  7. pod --version to test.

回答by Marc

Running these 2 lines will resolve your problem

运行这两行将解决您的问题

sudo gem update --system

sudo gem install cocoapods

须藤宝石更新--系统

sudo gem 安装 cocoapods

回答by interrupt

Many of this issues are because of system-wide ruby installation and it forces developers to use "sudo" all the time (well, how many times we did "sudogem install cocoapods --pre"). I recently had the same issue trying to install a pre-released version of cocoapods (permissions were messed up). So here is a approached that worked for me.

许多此类问题是由于系统范围的 ruby​​ 安装造成的,它迫使开发人员一直使用“sudo”(好吧,我们做了多少次“ sudogem install cocoapods --pre”)。我最近在尝试安装 cocoapods 的预发布版本时遇到了同样的问题(权限搞砸了)。所以这是一个对我有用的方法。

$ sudo gem uninstall xcodeproj 
$ sudo gem uninstall cocoapods

# Let's restore Apple's ruby installation, the following is for Yosemite that has 2.0 ruby by default 
$ cd /System/Library/Frameworks/Ruby.framework/Versions
$ sudo rm Current
$ sudo ln -s 2.0 Current 
$ brew install ruby

(closing and opening terminal window sometimes help)

(关闭和打开终端窗口有时会有所帮助)

$ which ruby

should display /usr/local/bin/ruby(should point to "local" directory now, not to "/usr/bin", if this is not the case for you, make sure to modify path order)

应该显示/usr/local/bin/ruby(现在应该指向“local”目录,而不是“/usr/bin”,如果不是这种情况,请确保修改路径顺序)

Now you should be able to install xcodeproj and cocoapods without using "sudo":

现在您应该能够在不使用“sudo”的情况下安装 xcodeproj 和 cocoapods:

$ gem install xcodeproj --pre
$ gem install cocoapods --pre

(I'm using pre-released version, just remove --pre if you want to use releases instead).

(我使用的是预发布版本,如果你想使用发布版本,只需删除 --pre )。

Enjoy :)

享受 :)

回答by JoeLaws

I had to uninstall the entire dependency chain for cocoapods to get it to work.

我不得不卸载 cocoapods 的整个依赖链才能让它工作。

for i in `gem list --no-versions`; do gem uninstall -aIx $i; done

see Uninstall all installed gems, in OSX?

请参阅在 OSX 中卸载所有已安装的 gem?

回答by kenorb

The error 'require': cannot load such fileindicates that you some missing or broken gem package. You can probably fix it by re-installing cocoapods:

该错误'require': cannot load such file表明您缺少或损坏了一些 gem 包。您可以通过重新安装 cocoapods 来修复它:

gem uninstall cocoapods # Follow by sudo if necessary
gem install cocoapods --verbose # Follow by sudo if necessary

And make sure that your xcodeproj is present:

并确保您的 xcodeproj 存在:

gem install xcodeproj --verbose # Follow by sudo if necessary


If won't help, try to install it by using older Ruby:

如果没有帮助,请尝试使用较旧的 Ruby 安装它:

sudo ln -s /Library/Ruby/Gems/1.8/gems/rubygems-update-1.8.12/bin/gem /usr/bin/gem18
sudo gem18 install cocoapods

See:

看:

回答by tryp

You just have to execute this commande before :

你只需要在之前执行这个命令:

sudo gem install cocoapods

This will update all outdated gems

这将更新所有过时的宝石