安装cocoapods遇到的几点问题

一、安装顺序:Homebrew->rvm->ruby->cocoapods


二、安装cocoapods,报错:activesupport requires Ruby version >= 2.2.2,如下图:

      解决办法:

      1、更新Gem: 

           sudo gem update --system

      2、卸载Homebrew:

            ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

      3、重新安装Homebrew: 

            ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

      4、安装rvm2.3.1: 

            rvm install 2.3.1

      5、安装cocoapods: 

           sudo gem install cocoapods


三、第一次使用pod install前,需要先pod setup。

      CocoaPods会将这些podspec索引文件更新到本地的 ~/.cocoapods/目录下,这个索引文件比较大,有80M左右。

所以第一次更新时非常慢。此时,可以更换repo镜像源为国内源,参考http://www.jianshu.com/p/3086df14ed08

      ps:很奇怪的是,我更换源的时候,总是会报错:[!] To setup the master specs repo, please run `pod setup`.

没办法,只好使用默认源,慢慢下载了....知道原因的麻烦知会一下,,哈哈!


四、执行pod install,报错:

       [!] 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`.

       这是因为包含所有第三方库的repo还没下载到本地,解决办法:

       1、pod repo add master https://github.com/CocoaPods/Specs.git

       注意:如果xcode装了多个版本,会出现以下错误:

       [!] /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


五、查看版本命令

1、查看ruby:ruby -v

2、查看cocoapods:pod --version



更新:

1、cocoapods1.0.1,使用github源,pod setup 用了足足一个多小时,共754M!!!

2、Xcode 7.0 beta 使用AFNetworking 3.1.0,总是会报20多个__nullable和__nonnull错误,降到3.0.0版本才可以。

3、项目中使用AFNetworking,出现“library not found -lafnetworking”,原因可能是Library Search Paths不正确,尤其是项目本来就设置了库路径的情况。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容