cocoapod 镜像切换

今天用另一台电脑使用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 ***

https://ruby.taobao.org/

$ 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 ***

https://gems.ruby-china.com/

开始安装
$ 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

cocoapod 镜像切换_第1张图片
正在安装.png
cocoapod 镜像切换_第2张图片
安装pod.png

为让模拟器也可以工作,再加一句
sudo xcode-select --switch /Applications/Xcode.app

//将 CocoaPods Specs repository复制到你电脑上~/.cocoapods目录下
pod setup
等待……

  • 如果安装失败,在文件夹目录 ~/.cocoapods 里面是空的,就需要重新setup
    命令如下:
    $ pod repo remove master #清空
查看是否有master文件夹.png

$ pod setup

cocoapod 镜像切换_第3张图片
屏幕快照 2019-05-27 下午6.27.52.png

此时已经成功安装了CocoaPods

  • $ pod search AFNetworking
    (可以用这个命令检查是否安装成功)

你可能感兴趣的:(cocoapod 镜像切换)