1. 检测gem版本
$ gem -v
2. 更新gem(gem版本高于2.7.x可跳过此步)
检测ruby源,更新gem需要官方的ruby源
$ gem sources -l
$ gem sources --add https://gems.ruby-china.com --remove xxx.xxx
如果遇到权限问题加上sudo, 输入密码即可
$ sudo gem sources --add https://gems.ruby-china.com --remove https://ruby.taobao.org/
$ gem sources -l
$ gem update --system
将ruby源切换回国内的
$ gem sources --add https://gems.ruby-china.com/--remove https://rubygems.org/
$ gem sources -l
3. 更新cocoapods
$ gem install cocoapods -n /usr/local/bin