1、更新指定的第三方库命令
pod install --verbose --no-repo-update
pod update --verbose --no-repo-update
2、安装指定版本的cocoapods
sudo gem install cocoapods --version 0.39.0
3、如果之前装过cocopods,最好先卸载掉,卸载命令:
$ sudo gem uninstall cocoapods
4、先查看本地安装过的cocopods相关东西,命令如下:
$ gem list --local | grep cocoapods
会显示如下:
cocoapods-core (0.39.0)
cocoapods-downloader (0.9.3)
cocoapods-plugins (0.4.2)
cocoapods-search (0.1.0)
cocoapods-stats (0.6.2)
cocoapods-trunk (0.6.4)
cocoapods-try (0.5.1)
然后逐个删除吧:
$ sudo gem uninstall cocoapods-core
$ sudo gem uninstall cocoapods-downloader
etc...
5、cocoapods安装流程
- 查看ruby:
ruby -v
- 查看源:
gem sources -l
- 移除源:
gem sources --remove https://rubygems.org/
- 设置新的源:
gem sources -a https://ruby.taobao.org/
- 验证是否替换成功:
gem sources -l
- 升级gem:
sudo gem update --system
- 安装CocoaPods(OS X 10.11以前):
sudo gem install cocoapods
- 安装CocoaPods(OS X 10.11以后):
sudo gem install -n /usr/local/bin cocoapods
- pod setup(
cd ~/.cocoapods/
跳转到目录下用命令du -sh *
查看下载进度)
6、cocoapods升级遇到的问题
1)运行sudo gem update --system报错
Updating rubygems-update
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/update_rubygems
原因:brew更新或重装的时候导致的我们电脑上没有ruby环境了,需要重新安装一下
解决方案:安装ruby:brew install ruby
安装Homebrew:
// 网址:http://brew.sh/
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2)执行pod update遇到的问题
出现:“Performing a deep fetch of themasterspecs repo to improve future performance”。
解决方案: 删除索引库,重新安装Pod,执行终端命令:
rm -rf ~/.cocoapods/repos
pod setup
3)执行pod setup遇到的问题1
问题1:
[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master
Cloning into 'master'...
error: RPC failed; result=56, HTTP code = 200
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
解决方案:
cd 任意的一个使用Git的项目
#执行
git repack --max-pack-size=500m -a -d
pod setup
问题2:
[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master
Cloning into 'master'...
error: RPC failed; curl 56 SSLRead() return error -36
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
解决办法:
You can try adding it manually in ~/.cocoapods/repos
or via pod repo add
.
自己按照提示在终端输入以下命令:
pod repo add master https://github.com/CocoaPods/Specs.git
还是报错!
在终端输入以下命令:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developers
后面的地址你可以打开Xcode显示包内容,找到那个文件夹拖到终端里面。
4)pod search 搜索类库失败的解决办法
- 执行
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'
这时就需要继续下面的步骤了。
- 删除
~/Library/Caches/CocoaPods
目录下的search_index.json
文件
pod setup
成功后,依然不能pod search
,是因为之前你执行pod search
生成了search_index.json
,此时需要删掉。
终端输入:rm ~/Library/Caches/CocoaPods/search_index.json
删除成功后,再执行pod search
。
执行pod search
终端输入:pod search afnetworking
(不区分大小写)
输出:Creating search index for spec repo 'master'.. Done!
,稍等片刻······就会出现所有带有afnetworking字段的类库。
5)pod install
库失败
Cloning into 'master'...
error: RPC failed; curl 56 SSLRead() return error -9806
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
解决办法:
$ brew remove git
$ brew remove curl
$ brew install openssl
$ brew install --with-openssl curl
$ brew install --with-brewed-curl --with-brewed-openssl git