1. 更新ruby
sudo gem update --system
2. 查看镜像
gem sources -l
3. 更改镜像路径
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
4. 安装cocopods
sudo gem install cocoapods
可能报错:
You don't have write permissions for the /usr/bin directory.
解决:
sudo gem install cocoapods -n /usr/local/bin
或者
重启电脑,长按commond+R, 进入recovery模式,进入终端输入csrutil disable回车,然后重启电脑