1、查看ruby源
gem sources -l
2、移除掉原有的源
gem sources --remove https://rubygems.org/
3、移除旧版
gem sources --remove https://rubygems.org/
4、添加镜像(以前是http,现在用https了)
gem sources --add https://gems.ruby-china.com/
5、检查是否添加成功
gem sources -l
5、安装cocoapods
sudo gem install -n /usr/local/bin cocoapods
6、安装完成后查看pod版本
pod --version
7、gem版本过老
如果直接输入
sudo gem install cocoapods
或者
sudo gem install -n /usr/local/bin cocoapods
可能或出现如下错误
ERROR: While executing gem ... (Gem::DependencyError)
Unable to resolve dependencies: cocoapods requires cocoapods-core (= 0.33.1), claide(~> 0.6.1), cocoapods-downloader(~> 0.6.1), cocoapods-plugins(~> 0.2.0), cocoapods-try(~> 0.3.0), cocoapods-trunk(~> 0.1.1), nap(~> 0.7)
8 查看gem版本
gem --version
9、升级gem版本
sudo gem update --system
10、安装CocoaPods