今天用另一台电脑使用pod时,发现cocoapod版本过低,想升级一下,然后发现淘宝镜像不能用了,于是更换镜像,下面是具体步骤:
- 重新升级Ruby环境
$ sudo gem update --system
ERROR: SSL verification error at depth 0: certificate has expired (10)
ERROR: Certificate /C=CN/ST=ZheJiang/L=HangZhou/O=Alibaba (China) Technology Co., Ltd./CN=*.taobao.org expired at 2018-12-05T03:16:02Z
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https: //ruby.taobao.org/specs.4.8.gz)
(淘宝镜像(https://ruby.taobao.org/)已经不可以使用了,查找到现在可以使用最新支持的ruby镜像(https://gems.ruby-china.com/))
- 替换镜像:
$which pod
/usr/local/bin/pod
$sudo rm -rf 路径 #移除该路径
$ gem sources -l
*** CURRENT SOURCES ***
$ gem sources --remove https://ruby.taobao.org/ #移除这个镜像资源
https://ruby.taobao.org/ removed from sources
(添加新镜像,目前由 ruby-china 提供,参考:https://www.cnblogs.com/wf0117/p/9393430.html)
$ gem sources -a https://gems.ruby-china.com/
https://gems.ruby-china.com/ added to sources
gem sources -l #查看是否添加替换成功
*** CURRENT SOURCES ***
开始安装
$ sudo gem install cocoapods
出现这种错误:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory.
(在mac OS 10.11以后去掉了直接安装cocoapods,所以需要自己添加)
$ sudo gem install -n /usr/local/bin cocoapods
为让模拟器也可以工作,再加一句
sudo xcode-select --switch /Applications/Xcode.app
//将 CocoaPods Specs repository复制到你电脑上~/.cocoapods目录下
pod setup
等待……
- 如果安装失败,在文件夹目录 ~/.cocoapods 里面是空的,就需要重新setup
命令如下:
$ pod repo remove master #清空
$ pod setup
此时已经成功安装了CocoaPods
- $ pod search AFNetworking
(可以用这个命令检查是否安装成功)