1、首先查看自己的Ruby默认源,命令:gem sources -l

如果以前没有修改过Ruby的源,那么这里便是第一次查看的结果。
2、移除源并且更新源,命令:gem sources --remove https://rubygems.org/,gem sources -a https://ruby.taobao.org/然后查看现在的ruby源:gem sources -l,效果如下

3、安装CocoaPodsd的命令为:sudo gem install cocoapods或者sudo gem install -n /usr/local/bin cocoa pods,但是当输入后会出现错误如下,更具提示需要升级ruby

4、实现ruby的安装。查看当前的ruby的版本我的版本如下:命令:ruby -v

首先安装 Ruby Version Manager,Ruby版本管理器,包括Ruby的版本管理和Gem库管理(gems),命令为:curl -L get.rvm.io | bash -s stable

随后对bash进行更新,命令如下:source ~/.bashrc ,source ~/.bash_profile

使用命令查看已经知道的ruby的版本:rvm list known,这里选择安装的是2.2.2的ruby版本:rvm install 2.2.2 如图:

等待的时间和个人的网速有关,等待完成就可以安装cocoapods
命令如下:sudo gem install cocoa pods

下面就可以编写Podfile文件了。
网友评论