前言
由于項(xiàng)目開發(fā)需要運(yùn)用第三發(fā)庫太多了,每下載一個(gè)第三個(gè)庫都要去查看他的配置介紹然而就會(huì)一個(gè)一個(gè)的去引用系統(tǒng)的庫,還有第三方庫的管理問題,于是前段時(shí)間選擇使用cocoapods 進(jìn)行管理。每個(gè)程序員都有兩臺(tái)電腦(一臺(tái)公司的,一臺(tái)自己的),在公司配置完成,經(jīng)過重重配置遇到問題解決,終于配置完成。突然發(fā)現(xiàn)自己電腦也要配置,然后之前遇到的問題也一個(gè)一個(gè)的又去查(這不是坑自己?jiǎn)幔K懔俗鳛槌绦騿T還是寫點(diǎn)博客比較好,記錄自己所遇到的問題和自己的知識(shí);方便你我,方便閱讀的人。
標(biāo)簽
RVM,Ruby,CocoaPods
安裝 RVM
RVM:Ruby Version Manager,Ruby版本管理器,包括Ruby的版本管理和Gem庫管理(gemset)
向終端輸入以下代碼安裝RVM
$ curl -L get.rvm.io | bash -s stable
指定源
$ source ~/.rvm/scripts/rvm
安裝成功后(由于安裝會(huì)向網(wǎng)絡(luò)下載文件可能會(huì)提示安裝失敗)向終端輸入代碼查看成功版本
$ rvm -v
終端控制臺(tái)會(huì)出現(xiàn)
rvm 1.27.0 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
使用RVM 升級(jí)或者安裝Ruby
Ruby一般Mac系統(tǒng)都會(huì)自帶不需要安裝升級(jí),但是我安裝的時(shí)候遇到Ruby版本過低提示錯(cuò)誤信息Error installing pods:activesupport requires Ruby version >= 2.2.2.,所以需要rvm對(duì)Ruby進(jìn)行升級(jí)
終端輸入
$ ruby -v
可查看當(dāng)前系統(tǒng)Ruby版本
ruby 2.0.0p648 (2015-12-16 revision 53155) [x86_64-darwin15]
所以我們需要對(duì)ruby進(jìn)行升級(jí)
查看rvm版本
rvm list known
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.8]
[ruby-]2.2[.4]
[ruby-]2.3[.0]
[ruby-]2.2-head
ruby-head
# for forks use: rvm install ruby-head-<name> --url https://github.com/github/ruby.git --branch 2.2
# JRuby
jruby-1.6[.8]
jruby-1.7[.23]
jruby[-9.0.5.0]
jruby-head
# Rubinius
rbx-1[.4.3]
rbx-2.3[.0]
rbx-2.4[.1]
rbx[-2.5.8]
rbx-head
# Opal
opal
# Minimalistic ruby implementation - ISO 30170:2012
mruby[-head]
# Ruby Enterprise Edition
ree-1.8.6
ree[-1.8.7][-2012.02]
# GoRuby
goruby
# Topaz
topaz
# MagLev
maglev[-head]
maglev-1.0.0
# Mac OS X Snow Leopard Or Newer
macruby-0.10
macruby-0.11
macruby[-0.12]
macruby-nightly
macruby-head
# IronRuby
ironruby[-1.1.3]
ironruby-head
安裝Ruby 輸入
rvm install 2.2
終端輸出太長,就不打印了
使用Ruby 安裝CocoaPods
使用淘寶的Ruby鏡像訪問cocoapods,官方代碼
$ gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
$ gem sources -l
兩句命令結(jié)果分別是
https://gems.ruby-china.org/ added to sources
#這個(gè)我已經(jīng)切換過了
source https://rubygems.org/ not present in cache
*** CURRENT SOURCES ***
https://ruby.taobao.org/
https://gems.ruby-china.org/
接下來就直接安裝CocoaPods
sudo gem install cocoapods
終端輸出表示成功
Password:
Fetching: activesupport-4.2.7.1.gem (100%)
Successfully installed activesupport-4.2.7.1
Fetching: claide-1.0.1.gem (100%)
Successfully installed claide-1.0.1
Fetching: cocoapods-core-1.1.1.gem (100%)
Successfully installed cocoapods-core-1.1.1
Fetching: cocoapods-downloader-1.1.2.gem (100%)
Successfully installed cocoapods-downloader-1.1.2
Fetching: cocoapods-trunk-1.1.1.gem (100%)
Successfully installed cocoapods-trunk-1.1.1
Fetching: fourflusher-2.0.1.gem (100%)
Successfully installed fourflusher-2.0.1
Fetching: gh_inspector-1.0.2.gem (100%)
Successfully installed gh_inspector-1.0.2
Fetching: molinillo-0.5.2.gem (100%)
Successfully installed molinillo-0.5.2
Fetching: xcodeproj-1.3.3.gem (100%)
Successfully installed xcodeproj-1.3.3
Fetching: cocoapods-1.1.1.gem (100%)
Successfully installed cocoapods-1.1.1
Parsing documentation for activesupport-4.2.7.1
Installing ri documentation for activesupport-4.2.7.1
Parsing documentation for claide-1.0.1
Installing ri documentation for claide-1.0.1
Parsing documentation for cocoapods-core-1.1.1
Installing ri documentation for cocoapods-core-1.1.1
Parsing documentation for cocoapods-downloader-1.1.2
Installing ri documentation for cocoapods-downloader-1.1.2
Parsing documentation for cocoapods-trunk-1.1.1
Installing ri documentation for cocoapods-trunk-1.1.1
Parsing documentation for fourflusher-2.0.1
Installing ri documentation for fourflusher-2.0.1
Parsing documentation for gh_inspector-1.0.2
Installing ri documentation for gh_inspector-1.0.2
Parsing documentation for molinillo-0.5.2
Installing ri documentation for molinillo-0.5.2
Parsing documentation for xcodeproj-1.3.3
Installing ri documentation for xcodeproj-1.3.3
Parsing documentation for cocoapods-1.1.1
Installing ri documentation for cocoapods-1.1.1
Done installing documentation for activesupport, claide, cocoapods-core, cocoapods-downloader, cocoapods-trunk, fourflusher, gh_inspector, molinillo, xcodeproj, cocoapods after 12 seconds
10 gems installed
再進(jìn)行pod安裝
$pod setup
下一篇進(jìn)行cocoapods 使用pod 項(xiàng)目操作