升级CocoaPods的步骤和安装的时候差不多,具体参考如下步骤:
1. 首先我们可以查看下当前的版本号命令如下:
pod --version
1.2.0 // 本机安装的版本
2. 在升级之前我们需要了解当前安装的Ruby源地址:
gem source -l
*** CURRENT SOURCES ***
http://rubygems.org/
https://gems.ruby-china.com/
https://ruby.taobao.org/
上面我已经添加过新的源
3. 移除淘宝的Ruby源,添加一个新的源(注意:目前淘宝的源已经不能用了)
// 移除旧的源: gem sources --remove https://ruby.taobao.org/ https://ruby.taobao.org/ removed from sources
// 添加新的源:gem sources -a https://gems.ruby-china.com
/// 因为已经添加过了sourcehttps://gems.ruby-china.com/ already presentinthe cache
4. 查看新的源是否添加成功,使用的命令和步骤2一样
gem source -l
*** CURRENT SOURCES ***
https://gems.ruby-china.com/
5. 开始安装,输入如下命令:
sudo gem install cocoapods
然后会出现下面的东西
cocoapodsPassword:Fetching: cocoapods-core-1.5.0.gem (100%)Successfully installed cocoapods-core-1.5.0Fetching: claide-1.0.2.gem (100%)Successfully installed claide-1.0.2Fetching: cocoapods-deintegrate-1.0.2.gem (100%)Successfully installed cocoapods-deintegrate-1.0.2Fetching: cocoapods-downloader-1.2.0.gem (100%)Successfully installed cocoapods-downloader-1.2.0Fetching: netrc-0.11.0.gem (100%)Successfully installed netrc-0.11.0Fetching: cocoapods-trunk-1.3.0.gem (100%)Successfully installed cocoapods-trunk-1.3.0Fetching: molinillo-0.6.5.gem (100%)Successfully installed molinillo-0.6.5Fetching: atomos-0.1.2.gem (100%)Successfully installed atomos-0.1.2Fetching: colored2-3.1.2.gem (100%)Successfully installed colored2-3.1.2Fetching: nanaimo-0.2.5.gem (100%)Successfully installed nanaimo-0.2.5Fetching: xcodeproj-1.5.7.gem (100%)Successfully installed xcodeproj-1.5.7Fetching: ruby-macho-1.1.0.gem (100%)Successfully installed ruby-macho-1.1.0Fetching: cocoapods-1.5.0.gem (100%)Successfully installed cocoapods-1.5.0Parsing documentationforcocoapods-core-1.5.0Installing ri documentationforcocoapods-core-1.5.0Parsing documentationforclaide-1.0.2Installing ri documentationforclaide-1.0.2Parsing documentationforcocoapods-deintegrate-1.0.2Installing ri documentationforcocoapods-deintegrate-1.0.2Parsing documentationforcocoapods-downloader-1.2.0Installing ri documentationforcocoapods-downloader-1.2.0Parsing documentationfornetrc-0.11.0Installing ri documentationfornetrc-0.11.0Parsing documentationforcocoapods-trunk-1.3.0Installing ri documentationforcocoapods-trunk-1.3.0Parsing documentationformolinillo-0.6.5Installing ri documentationformolinillo-0.6.5Parsing documentationforatomos-0.1.2Installing ri documentationforatomos-0.1.2Parsing documentationforcolored2-3.1.2Installing ri documentationforcolored2-3.1.2Parsing documentationfornanaimo-0.2.5Installing ri documentationfornanaimo-0.2.5Parsing documentationforxcodeproj-1.5.7Installing ri documentationforxcodeproj-1.5.7Parsing documentationforruby-macho-1.1.0Installing ri documentationforruby-macho-1.1.0Parsing documentationforcocoapods-1.5.0Installing ri documentationforcocoapods-1.5.0Done installing documentationforcocoapods-core, claide, cocoapods-deintegrate, cocoapods-downloader, netrc, cocoapods-trunk, molinillo, atomos, colored2, nanaimo, xcodeproj, ruby-macho, cocoapods after 9 seconds13 gems installed
可能会报错:
Operation not permitted - /usr/bin/xcodeproj
解决办法:sudo gem install -n /usr/local/bin cocoapods
While executing gem ... (TypeError) no implicit conversion of nil into String
// 解决办法是执行如下命令更新gemsudo gem update --system复制代码
6. 再次查看下CocoaPods的版本,已经成功升级咯!
pod --version1.5.0