1、首先查看当前pod 的版本:
pod --version
截止当前2019年2月26号最新版本号:1.6.1
2、了解当前Ruby的源地址
gem source -l
*** CURRENT SOURCES *** http://rubygems.org/ https://gems.ruby-china.org/ https://ruby.taobao.org/
3、以前都是淘宝源,现在都不能用了,删除统一改为https://gems.ruby-china.com/
// 移除旧的源gem sources --remove https://ruby.taobao.org/https://ruby.taobao.org/ removed from sources//
添加新的源gem sources -a https://gems.ruby-china.com/
4、查看新的源是否添加成功,使用的命令和步骤2一样
gem source -l
*** CURRENT SOURCES ***
https://gems.ruby-china.org/
5. 开始安装,输入如下命令:
sudo gem install cocoapods
Password:
Fetching: cocoapods-core-1.5.0.gem (100%)
Successfully installed cocoapods-core-1.5.0
Fetching: cocoapods-trunk-1.3.0.gem (100%)
Successfully installed cocoapods-trunk-1.3.0
ntegrate-1.0.2
Installing ri documentation for cocoapods-deintegrate-1.0.2
Parsing documentation for molinillo-0.6.5
Installing ri documentation for molinillo-0.6.5
Done installing documentation for cocoapods-core, claide, cocoapods-deintegrate, cocoapods-downloader, netrc, cocoapods-trunk, molinillo, atomos, colored2, nanaimo, xcodeproj, ruby-macho, cocoapods after 9 seconds
13 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 --version
1.6.1
7、pod search 总是报异常错误
[!] Unable to find a pod with name, author, summary, or descriptionmatching '······'
7.1.执行pod setup
其实在你安装CocoaPods执行pod install时,系统会默认操作pod setup,然而由于中国强大的墙可能会pod setup不成功。这时就需要手动执行pod setup指令,如下:
终端输入:pod setup
会出现Setting up CocoaPods master repo,稍等几十秒,最底下会输出Setup completed。说明执行pod setup成功。
如果pod search操作还是搜索失败,如下:
终端输入:pod search AFNetworking
输出:Unable to find a pod with name, author, summary, or descriptionmatching 'AFNetworking' 这时就需要继续下面的步骤了。
7.2.删除~/Library/Caches/CocoaPods目录下的search_index.json文件
pod setup成功后,依然不能pod search,是因为之前你执行pod search生成了search_index.json,此时需要删掉。
终端输入:rm ~/Library/Caches/CocoaPods/search_index.json
删除成功后,再执行pod search。
7.3.执行pod search
终端输入:pod search afnetworking(不区分大小写)
输出:Creating search index for spec repo 'master'.. Done!,稍等片刻······就会出现所有带有afnetworking字段的类库。
网友评论