总的顺序为:
Xcode->Homebrew->RVM->Ruby->CocoaPods
一、配置Mac的Ruby环境
1、Xcode 略去;
2、Homebrew:是一个包管理器,用于在mac上安装一些os x上没有的UNiX工具(比如wget)。(官方网站:http://brew.sh/index_zh-cn.html)
安装命令:
$ /usr/bin/ruby -e "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/master/install)"
3、RVM(Ruby Version Manager)
[官网:https://cache.ruby-lang.org/pub/ruby/ ]
安装:
a、$ curl -L https://get.rvm.io | bash -s stable
b、$ source ~/.rvm/scripts/rvm (刚装好需要执行命令手动载入环境,下次再开会自动载入)
b、$ rvm -v (检查一下是否安装正确:)
c、$ rvm install 2.3.1 (安装 Ruby)
二、CocoaPods的安装
1、$ sudo gem update --system(升级Ruby环境,非必要)
2、安装CocoaPods时我们要访问cocoapods.org(被墙),用淘宝的RubyGems镜像来代替官方版本:
a、$ gem sources --remove https://rubygems.org/
b、 $ gem sources -a https://ruby.taobao.org/ (等a命令有反应之后)
c、$ gem sources -l (验证Ruby镜像是并且仅是taboo)
d、$ sudo gem install cocoapods (终极安装命令)
结果大概如下图(之前先执行了:gem sources --remove https://rubygems.org/)
出现下图这种,安装成功!!
参考:
http://www.2cto.com/kf/201411/348389.html
http://www.jianshu.com/p/c29db1c6713d