安装cocoapods
1.检查ruby的版本
在终端中输入 ruby -v
如果终端中返回的版本过低(2.2.2)就需要更新
2.更换镜像
在终端中输入 gem sources -l,可以查看当前镜像源,默认是https://rubygems.org/。
如果没有翻墙,就要更换镜像源
首先要移除,在终端中输入
gem sources --remove https://rubygems.org/
然后添加国内镜像,在终端输入
gem sources -a https://gems.ruby-china.com/
3.更新ruby
在终端中输入
sudo gem update --system
4.安装cocoapods
终端输入
sudo gem install cocoapods
输入后如果报错
Error installing cocoapods: ERROR: Failed to build gem native extension.
那么安装rvm
在终端输入 curl -L https://get.rvm.io | bash -s stable
如果安装不了,那就换个方法
安装homebrew
国内用户可以在终端中输入
/bin/zsh -c “$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)”
安装都是自动的,安装结束后新打开终端。
终端输入
brew install cocoapods