CocoaPods安装过程

0.安装前奏
由于ruby软件源ruby gems.org使用亚马逊云服务而被屏蔽,故需更新ruby源,将官方的ruby源替换成国内淘宝的源

gem sources --remove https://rubygems.org/ 
gem sources -a https://ruby.taobao.org/
gem sources -l //查看ruby源

1.环境配置
我的OSX 是10.11, OSX自带Ruby环境为2.x,由于之前搭建博客选用Ruby 1.9.x ,导致遇cocoapods-core requires Ruby version >= 2.0.0.需要解决的问题就是实现Ruby版本的提升。

使用Home-brew安装Ruby

//安装brew(Homebrew)
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update//更新brew支持的最新版本
brew install ruby//抓取最新版本并安装
ruby --version 依旧是 ruby 1.9.3p551
$ rvm list

rvm rubies

=* ruby-1.9.3-p551 [ x86_64 ]

# => - current
# =* - current && default
#  * - default
$ brew install readline ruby-build rbenv
$ rbenv install -l//查看可用的ruby版本
$ rbenv install 2.3.0
rbenv versions//查看已安装的所有Ruby版本,显示如下
  system
* 1.9.3-p125 (set by /Users/userxx/.ruby-version)//*为当前激活版本
  2.3.0
rbenv local 2.3.0//版本安装后更改(设置本地版本)
$ ruby -v//但是并不能实现版本切换,显示如下
ruby 1.9.3p551 
//附加路径的设定
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
//重新加载设置,并查看版本号
$ source ~/.bash_profile
$ ruby -v
ruby 2.3.0p0//显示

以上是版本切换的实现完成。
2.安装

sudo gem install cocoapods
22 gems installed//显示
pod setup //显示如下(1)
/Users/muser/.rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/rubygems.rb:250:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) (Gem::GemNotFoundException)
    from /Users/muser/.rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/rubygems.rb:278:in `activate_bin_path'
    from /Users/muser/.rbenv/versions/2.3.0/bin/pod:22:in `
'
$ rvm install ruby-2.3.0
$ rvm reinstall ruby-2.3.0
$ pod setup//显示如(1)
$ sudo gem uninstall cocoapods
$ gem install cocoapods
$ pod setup //显示如下
Setting up CocoaPods master repo
Setup completed
find_spec_for_exe': can't find gem cocoapods (>= 0.a) (Gem::GemNotFoundException)
from /Users/sibo/.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems.rb:278:inactivate_bin_path'
from /Users/sibo/.rvm/rubies/ruby-2.0.0-p648/bin/pod:22:in `'
//解决如下:
1: sudo gem uninstall cocoapods

2: gem install cocoapods

3: pod install

参考:
https://github.com/ruby-china/ruby-china/wiki/Mac-OS-X-上安装-Ruby
http://www.imike.me/2016/04/19/使用rbenv安装和管理Ruby版本/
http://qiita.com/dmzero3/items/a7fad05803ac781c172d

你可能感兴趣的:(工具)