确认Ruby环境存在
如果不存在,可以通过homebrew安装brew install ruby
。或者通过rvm
安装。
ruby -v
首先更换源
gem sources --add https://gems.ruby-china.com/
gem sources --remove https://rubygems.org/
然后gem sources -l
查看是否正确,仅有https://gems.ruby-china.com/
就对了:
#gem sources -l
*** CURRENT SOURCES ***
https://gems.ruby-china.com/
更新Ruby
sudo gem update --system
安装cocoapods
sudo gem install -n /usr/local/bin cocoapods
确认安装成功
pod --version