我已经尝试过这个步骤:
但是当我进行pod安装或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>'
答案 0 :(得分:21)
如果其他人遇到同样的问题,我这样做是为了解决我的问题:
更新宝石
sudo gem update --system
已卸载xcodeproj
sudo gem uninstall xcodeproj
确保选择所有版本
卸载Cocoapods
sudo gem uninstall cocoapods
安装xcodeproj
sudo gem install xcodeproj
安装cocoapods
sudo gem install cocoapods
运行
pod --version to test.
答案 1 :(得分:20)
运行这两行将解决您的问题
sudo gem update --system
sudo gem install cocoapods
答案 2 :(得分:2)
我必须卸载cocoapods的整个依赖关系链才能使它工作。
for i in `gem list --no-versions`; do gem uninstall -aIx $i; done
答案 3 :(得分:2)
许多问题都是因为系统范围内的ruby安装,它迫使开发人员一直使用“sudo”(好吧,我们做了多少次“ sudo gem 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
(关闭并打开终端窗口有时会有帮助)
$ which ruby
应显示 / usr / local / bin / ruby (现在应该指向“本地”目录,而不是“/ usr / bin”,如果不是这种情况,请确保修改路径顺序)
现在你应该可以在不使用“sudo”的情况下安装xcodeproj和cocoapods:
$ gem install xcodeproj --pre
$ gem install cocoapods --pre
(我正在使用预发布版本,如果你想使用版本,只需删除--pre。)
享受:)
答案 4 :(得分:0)
错误'require': cannot load such file
表示您有一些丢失或损坏的gem包。您可以通过重新安装cocoapods来修复它:
gem uninstall cocoapods # Follow by sudo if necessary
gem install cocoapods --verbose # Follow by sudo if necessary
确保您的xcodeproj存在:
gem install xcodeproj --verbose # Follow by sudo if necessary
如果没有帮助,请尝试使用较旧的Ruby安装它:
sudo ln -s /Library/Ruby/Gems/1.8/gems/rubygems-update-1.8.12/bin/gem /usr/bin/gem18
sudo gem18 install cocoapods
请参阅:
答案 5 :(得分:-2)
您必须先执行此命令:
sudo gem install cocoapods
这将更新所有过时的宝石