CocoaPods是用Ruby實現的,要想使用它首先須要有Ruby的環境。幸運的是OS X系統默認已經能夠運行Ruby了,所以咱們只需執行如下命令: sudo gem install -n /usr/local/bin cocoapods 因爲某些緣由,執行時會出現下面的錯誤提示: ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why: Unable to download data from https://rubygems.org/ - Errno::EPIPE: Broken pipe - SSL_connect (https://rubygems.org/latest_specs.4.8.gz) 當你使用代理後若是仍是很慢,能夠用淘寶的RubyGems鏡像來代替官方版本,執行如下命令: $ gem sources -l $ gem sources --remove https://rubygems.org/ $ gem sources -a https://ruby.taobao.org/ $ gem sources -l 安裝成功後,接着執行命令: pod setup 至此安裝就完成了,咱們能夠嘗試搜索一個第三方類庫: pod search AFNetworking
命令行更新步驟ruby
$ sudo gem update --system // 先更新gem,國內須要切換源spa
$ gem sources --remove https://rubygems.org/命令行
$ gem sources -a http://ruby.taobao.org/代理
$ gem sources -lcode
*** CURRENT SOURCES ***blog
http://ruby.taobao.org/ip
$ sudo gem install cocoapods // 安裝cocoapodsrem
$ pod setupget
和安裝過程是同樣的,再次查看版本pip
$ pod --version