一:安装CocoaPods
1: 更换更新源地址(ruby镜像),操作如下
移除原地址
$ gem sources --remove https://rubygems.org/
添加新地址
$ gem sources -a https://ruby.taobao.org/
查看当前地址
$ gem sources -l
2: 安装CocoaPods
$ sudo gem install cocoapods
3:查看当前CocoaPods版本
$ pod --version
二:常见报错
1.安装CocoaPods时出现错误 Operation not permitted - /usr/bin/pod
使用命令行
$ sudo gem install -n /usr/local/bin cocoapods
2.使用‘sudo gem update cocoapods’,报错:
ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/xcodeproj
原因:在stackoverflow搜到的解释是这样的,This is happening because Apple has enabled rootless on the new install,也就是说在10.11系统上苹果已经启用无根的安装。在这种情况下,如果你使用如下的命令:
$ sudo gem install -n /usr/local/bin cocoapods
3.cocoapods找不到第三方库Unable to find a pod with name, author, summary, or descriptionmatching
pod setup成功后,依然不能pod search,是因为之前你执行pod search生成了search_index.json,此时需要删掉。
终端输入:
$ rm ~/Library/Caches/CocoaPods/search_index.json
删除成功后,再执行pod search。
网友评论