Xcode8 升級Ruby 升級Cocoapods,遇到的坑及解決辦法释牺。

1.在升級到Xcode8之后Cocoapods管理第三方庫的時候萝衩,不報錯,但是卻沒安裝成功没咙,這個時候你就要查看當前的ruby版本猩谊,Xcode8必須要要ruby 2.2.0以上才可以。
2.$ ruby -v 查看當前版本祭刚,我的當時是2.0.0牌捷,明顯小于Cocoapods的最低要求墙牌。
3.首先要更新Ruby , 有三種選擇
1.下載ruby源代碼,編譯暗甥,安裝
2.使用發(fā)行版自帶的安裝包喜滨,安裝
3.使用 rvm安裝
我選擇了 rvm安裝, 那勢必得先安裝 rvm

1.RVM:Ruby Version Manager,Ruby版本管理器,包括Ruby的版本管理和Gem庫管理(gems)

$ curl -L get.rvm.io | bash -s stable

2.加載文件, 測試是否安裝正常(按照提示操作)

$ source ~/.bashrc 

$ source ~/.bash_profile 

$ source ~/.profile$ rvm -v

3.如果有下面的提示, 請reload rvm
A RVM version 1.27.0 (latest) is installed yet 1.25.23 (stable) is loaded.
Please do one of the following:

'rvm reload'
open a new shell
'echo rvm_auto_reload_flag=1 >> ~/.rvmrc' # for auto reload with msg.
'echo rvm_auto_reload_flag=2 >> ~/.rvmrc' # for silent auto reload.

輸入命令:

$ rvm reload
$ rvm -v

4.查看當前ruby版本 ,獲取rvm 列表

$ ruby -v 

$ rvm list known

5.安裝ruby可能出的錯誤 (若未出錯, 請?zhí)^進入第6步)
ERROR: While executing gem ... (Gem::Exception)
Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
這個時候你就要更改淘寶鏡像源

$ rvm install 2.4.0

6.ruby -v 查看當前鏡像版本號

  1. gem sources 如果出現(xiàn)如下結(jié)果


    屏幕快照 2017-01-16 下午3.43.35.png

    標識更換成功撤防。
    8.執(zhí)行 sudo gem install cocoapods --pre 即可

Password:
Fetching: thread_safe-0.3.5.gem (100%)
Successfully installed thread_safe-0.3.5
Fetching: tzinfo-1.2.2.gem (100%)
Successfully installed tzinfo-1.2.2
Fetching: concurrent-ruby-1.0.4.gem (100%)
Successfully installed concurrent-ruby-1.0.4
Fetching: i18n-0.7.0.gem (100%)
Successfully installed i18n-0.7.0
Fetching: json-1.8.6.gem (100%)
Building native extensions.  This could take a while...
Successfully installed json-1.8.6
Fetching: activesupport-4.2.7.1.gem (100%)
Successfully installed activesupport-4.2.7.1
Fetching: nap-1.1.0.gem (100%)
Successfully installed nap-1.1.0
Fetching: fuzzy_match-2.0.4.gem (100%)
Successfully installed fuzzy_match-2.0.4
Fetching: cocoapods-core-1.2.0.rc.1.gem (100%)
Successfully installed cocoapods-core-1.2.0.rc.1
Fetching: claide-1.0.1.gem (100%)
Successfully installed claide-1.0.1
Fetching: cocoapods-deintegrate-1.0.1.gem (100%)
Successfully installed cocoapods-deintegrate-1.0.1
Fetching: cocoapods-downloader-1.1.3.gem (100%)
Successfully installed cocoapods-downloader-1.1.3
Fetching: cocoapods-plugins-1.0.0.gem (100%)
Successfully installed cocoapods-plugins-1.0.0
Fetching: cocoapods-search-1.0.0.gem (100%)
Successfully installed cocoapods-search-1.0.0
Fetching: cocoapods-stats-1.0.0.gem (100%)
Successfully installed cocoapods-stats-1.0.0
Fetching: netrc-0.7.8.gem (100%)
Successfully installed netrc-0.7.8
Fetching: cocoapods-trunk-1.1.2.gem (100%)
Successfully installed cocoapods-trunk-1.1.2
Fetching: cocoapods-try-1.1.0.gem (100%)
Successfully installed cocoapods-try-1.1.0
Fetching: molinillo-0.5.5.gem (100%)
Successfully installed molinillo-0.5.5
Fetching: CFPropertyList-2.3.4.gem (100%)
Successfully installed CFPropertyList-2.3.4
Fetching: colored-1.2.gem (100%)
Successfully installed colored-1.2
Fetching: nanaimo-0.2.3.gem (100%)
Successfully installed nanaimo-0.2.3
Fetching: xcodeproj-1.4.2.gem (100%)
Successfully installed xcodeproj-1.4.2
Fetching: escape-0.0.4.gem (100%)
Successfully installed escape-0.0.4
Fetching: fourflusher-2.0.1.gem (100%)
Successfully installed fourflusher-2.0.1
Fetching: gh_inspector-1.0.3.gem (100%)
Successfully installed gh_inspector-1.0.3
Fetching: ruby-macho-0.2.6.gem (100%)
Successfully installed ruby-macho-0.2.6
Fetching: cocoapods-1.2.0.rc.1.gem (100%)
Successfully installed cocoapods-1.2.0.rc.1
Parsing documentation for thread_safe-0.3.5
Installing ri documentation for thread_safe-0.3.5
Parsing documentation for tzinfo-1.2.2
Installing ri documentation for tzinfo-1.2.2
Parsing documentation for concurrent-ruby-1.0.4
Installing ri documentation for concurrent-ruby-1.0.4
Parsing documentation for i18n-0.7.0
Installing ri documentation for i18n-0.7.0
Parsing documentation for json-1.8.6
Installing ri documentation for json-1.8.6
Parsing documentation for activesupport-4.2.7.1
Installing ri documentation for activesupport-4.2.7.1
Parsing documentation for nap-1.1.0
Installing ri documentation for nap-1.1.0
Parsing documentation for fuzzy_match-2.0.4
Installing ri documentation for fuzzy_match-2.0.4
Parsing documentation for cocoapods-core-1.2.0.rc.1
Installing ri documentation for cocoapods-core-1.2.0.rc.1
Parsing documentation for claide-1.0.1
Installing ri documentation for claide-1.0.1
Parsing documentation for cocoapods-deintegrate-1.0.1
Installing ri documentation for cocoapods-deintegrate-1.0.1
Parsing documentation for cocoapods-downloader-1.1.3
Installing ri documentation for cocoapods-downloader-1.1.3
Parsing documentation for cocoapods-plugins-1.0.0
Installing ri documentation for cocoapods-plugins-1.0.0
Parsing documentation for cocoapods-search-1.0.0
Installing ri documentation for cocoapods-search-1.0.0
Parsing documentation for cocoapods-stats-1.0.0
Installing ri documentation for cocoapods-stats-1.0.0
Parsing documentation for netrc-0.7.8
Installing ri documentation for netrc-0.7.8
Parsing documentation for cocoapods-trunk-1.1.2
Installing ri documentation for cocoapods-trunk-1.1.2
Parsing documentation for cocoapods-try-1.1.0
Installing ri documentation for cocoapods-try-1.1.0
Parsing documentation for molinillo-0.5.5
Installing ri documentation for molinillo-0.5.5
Parsing documentation for CFPropertyList-2.3.4
Installing ri documentation for CFPropertyList-2.3.4
Parsing documentation for colored-1.2
Installing ri documentation for colored-1.2
Parsing documentation for nanaimo-0.2.3
Installing ri documentation for nanaimo-0.2.3
Parsing documentation for xcodeproj-1.4.2
Installing ri documentation for xcodeproj-1.4.2
Parsing documentation for escape-0.0.4
Installing ri documentation for escape-0.0.4
Parsing documentation for fourflusher-2.0.1
Installing ri documentation for fourflusher-2.0.1
Parsing documentation for gh_inspector-1.0.3
Installing ri documentation for gh_inspector-1.0.3
Parsing documentation for ruby-macho-0.2.6
Installing ri documentation for ruby-macho-0.2.6
Parsing documentation for cocoapods-1.2.0.rc.1
Installing ri documentation for cocoapods-1.2.0.rc.1
Done installing documentation for thread_safe, tzinfo, concurrent-ruby, i18n, json, activesupport, nap, fuzzy_match, cocoapods-core, claide, cocoapods-deintegrate, cocoapods-downloader, cocoapods-plugins, cocoapods-search, cocoapods-stats, netrc, cocoapods-trunk, cocoapods-try, molinillo, CFPropertyList, colored, nanaimo, xcodeproj, escape, fourflusher, gh_inspector, ruby-macho, cocoapods after 27 seconds
28 gems installed

表示安裝成功
1.更換ruby鏡像

gem sources -l  //(用來檢查使用替換鏡像位置成功)查看當前鏡像

 gem sources --remove https://ruby.taobao.org/

 gem sources -a http://rubygems.org/

2.下載安裝CocoaPods

終端輸入:

    sudo gem install cocoapods 
    pod setup 

3.使用CocoaPods

cd到項目總目錄

$ vim Podfile

然后在Podfile文件中輸入以下文字:

platform :ios, '8.0'

target "targetName" do

pod 'AFNetworking'

end

然后按Esc虽风,并且輸入“:”號進入vim命令模式,然后在冒號后邊輸入wq

確定終端cd到項目總目錄寄月,然后輸入 pod install (安裝第三庫)

終端輸入命令:pod search UI (搜索第三庫)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末焰情,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子剥懒,更是在濱河造成了極大的恐慌,老刑警劉巖合敦,帶你破解...
    沈念sama閱讀 221,576評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件初橘,死亡現(xiàn)場離奇詭異,居然都是意外死亡充岛,警方通過查閱死者的電腦和手機保檐,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,515評論 3 399
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來崔梗,“玉大人夜只,你說我怎么就攤上這事∷馄牵” “怎么了扔亥?”我有些...
    開封第一講書人閱讀 168,017評論 0 360
  • 文/不壞的土叔 我叫張陵,是天一觀的道長谈为。 經(jīng)常有香客問我旅挤,道長,這世上最難降的妖魔是什么伞鲫? 我笑而不...
    開封第一講書人閱讀 59,626評論 1 296
  • 正文 為了忘掉前任粘茄,我火速辦了婚禮,結(jié)果婚禮上秕脓,老公的妹妹穿的比我還像新娘柒瓣。我一直安慰自己,他們只是感情好吠架,可當我...
    茶點故事閱讀 68,625評論 6 397
  • 文/花漫 我一把揭開白布芙贫。 她就那樣靜靜地躺著,像睡著了一般诵肛。 火紅的嫁衣襯著肌膚如雪屹培。 梳的紋絲不亂的頭發(fā)上默穴,一...
    開封第一講書人閱讀 52,255評論 1 308
  • 那天,我揣著相機與錄音褪秀,去河邊找鬼蓄诽。 笑死,一個胖子當著我的面吹牛媒吗,可吹牛的內(nèi)容都是我干的仑氛。 我是一名探鬼主播,決...
    沈念sama閱讀 40,825評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼闸英,長吁一口氣:“原來是場噩夢啊……” “哼锯岖!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起甫何,我...
    開封第一講書人閱讀 39,729評論 0 276
  • 序言:老撾萬榮一對情侶失蹤出吹,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后辙喂,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體捶牢,經(jīng)...
    沈念sama閱讀 46,271評論 1 320
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,363評論 3 340
  • 正文 我和宋清朗相戀三年巍耗,在試婚紗的時候發(fā)現(xiàn)自己被綠了秋麸。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,498評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡炬太,死狀恐怖灸蟆,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情亲族,我是刑警寧澤炒考,帶...
    沈念sama閱讀 36,183評論 5 350
  • 正文 年R本政府宣布寥茫,位于F島的核電站藕赞,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏封救。R本人自食惡果不足惜女气,卻給世界環(huán)境...
    茶點故事閱讀 41,867評論 3 333
  • 文/蒙蒙 一杏慰、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧炼鞠,春花似錦缘滥、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,338評論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至霎肯,卻和暖如春擎颖,著一層夾襖步出監(jiān)牢的瞬間榛斯,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,458評論 1 272
  • 我被黑心中介騙來泰國打工搂捧, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留驮俗,地道東北人。 一個月前我還...
    沈念sama閱讀 48,906評論 3 376
  • 正文 我出身青樓允跑,卻偏偏與公主長得像王凑,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子聋丝,可洞房花燭夜當晚...
    茶點故事閱讀 45,507評論 2 359

推薦閱讀更多精彩內(nèi)容