先安装 [Xcode]
步骤1 - 安装 RVM
$ curl -L https://get.rvm.io | bash -s stable
$ source ~/.rvm/scripts/rvm
$ rvm -v
rvm 1.22.17 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
步骤2 - 用 RVM 安装 Ruby 环境
$ rvm list known
可以选择现有的rvm版本来进行安装
$ rvm install 2.3.0
完成以后,Ruby, Ruby Gems 就安装好了。
查询已经安装的ruby
$ rvm list
卸载一个已安装版本
$ rvm remove 1.9.2
步骤3 - 设置 Ruby 版本
RVM 装好以后,需要执行下面的命令将指定版本的 Ruby 设置为系统默认版本
$ rvm 2.0.0 --default
$ ruby -v
$ gem -v
2.3.0
这有可能是因为Ruby的默认源使用的是cocoapods.org,国内访问这个网址有时候会有问题,解决方案是将远替换成淘宝的,替换方式如下:
$gem source -r https://rubygems.org/ $gem source -a https://ruby.taobao.org
$ gem sources -l
正常的输出结果:
CURRENT SOURCES
http://ruby.taobao.org/
出现过的问题:
shentudeMacBook-Pro:~ shentu$ pod setup
Setting up CocoaPods master repo
这条命令后一直卡着,然后等到最后会出现个错误:
[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master
Cloning into 'master'...
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
然后我尝试了很多办法,首先试着手动安装CocoaPods master repo,在网上下载了master,然后$ open 命令直接放进该放的地方,可是这样你用$du -sh查看文件大小会发现他只有45M,大概是版本太旧了。
shentudeMacBook-Pro:~ shentu$ pod repo remove master
Removing spec repo `master`
shentudeMacBook-Pro:~ shentu$ pod setup
Setting up CocoaPods master repo
shentudeMacBook-Pro:~ shentu$ cd ~/.cocoapods/
shentudeMacBook-Pro:.cocoapods shentu$ du -sh
719M .
然后就特么好了···迷。