OS X 10.11 安装Cocoapods 出现问题的解决方法
今天尝试用 Cocoapods安装个第三方库.. 输入pod install, 发现 command not find。 WTF!javascript
估计是升级10.11后Cocoapods被干掉了。java
我输入 sudo gem install cocoa pods 以后,出现以下问题:git
ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/xcodeproj
我估计是gem版本没有更新。执行sudo gem update –system,又出现了错误github
ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/update_rubygems
在Stackoverflow上找到了解决方法:xcode
由于知道gem版本过老的话也是不能成功下载cocoapods的,可是我如今又不能用sudo gem update –system来更新。后来我就直接去rubygems官网下载了最新的源码进行了安装。如今执行gem -v显示版本是2.4.8。
能够看我另一篇文章,手动安装gemruby
但是问题又来了,这个时候去执行sudo gem install cocoapods,仍是会出现上边的错误。
因此执行下边:app
自定义GEM_HOME
$ mkdir -p $HOME/Software/ruby
$ export GEM_HOME=$HOME/Software/ruby
$ gem install cocoapods
[...] 1 gem installed $ export PATH=$PATH:$HOME/Software/ruby/bin $ pod --version 0.38.2
GEM_PATH与GEM_HOME 的区别:ide
1.GEM_PATH provides the locations (there may be several) where gems can be found.
2.GEM_HOME is where gems will be installed (by default).(Therefore GEM_PATH should include GEM_HOME).ui
可是以后我pod install的时候又花式出错url
[!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `master`. You can try adding it manually in `~/.cocoapods/repos` or via `pod repo add`.
我尝试按提示的方法
pod repo add master https://github.com/CocoaPods/Specs.git
然而仍是有错..
[!] /usr/bin/git clone http://git.oschina.net/akuandev/Specs.git master xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
最后的解决方法:
sudo xcode-select -switch /Applications/Xcode-beta.app/Contents/Developers
后面的地址你能够打开Xcode显示包内容,找到那个文件夹拖到终端里面比较不容易错。
最后终于修成正果..
至于一开始输入 sudo gem install cocoapods 没反应须要修改成淘宝镜像的问题,请百度Cocoapods参阅其它文章..