直接执行sudo gem install cocoapods,会报错, ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/pod
替换成:sudo gem install -n /usr/local/bin cocoapods
然后又报错
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
网上查才知道taobao镜像已经改成https的了。
所以解决方案如下:
1、替换为淘宝镜像,注意是https
gem sources -a https://ruby.taobao.org/
2、执行以下命令
sudo gem install -n /usr/local/bin cocoapods