因?yàn)殡娔X升級(jí)了,突然準(zhǔn)備升級(jí)一下第三方框架,發(fā)現(xiàn)cocoapods用不了了。故重新安裝一下,但是過程還是出現(xiàn)很多問題,故來寫一篇文章記錄一下。
安裝cocoapods需要使用ruby環(huán)境,因?yàn)橐郧鞍惭b過,所以不需要再安裝了。如果沒有就去自行百度吧。因?yàn)橐话鉳ac系統(tǒng)都自帶安裝了。如果不知道自己有沒有ruby,可以用ruby -v 查看當(dāng)前ruby版本。
安裝:
首先 查看你的ruby源
$gem sources -l
我的返回的是我以前安裝的源
*** CURRENT SOURCES ***
https://ruby.taobao.org/
以前就是用的淘寶的,但是后面的改了,所以我就改了一個(gè)源。首先刪除原來的源。
gem sources --remove https://ruby.taobao.org/
執(zhí)行命令后:
https://ruby.taobao.org/ removed from sources
接下來就要添加可用的鏡像源
$ gem sources -a http://rubygems-china.oss.aliyuncs.com
執(zhí)行命令后:
http://rubygems-china.oss.aliyuncs.com added to sources
此時(shí)就可以安裝cocoapods
$ sudo gem install cocoapods
但是我這里出現(xiàn)了問題如下:
Fetching: gh_inspector-1.0.2.gem (100%)
Successfully installed gh_inspector-1.0.2
Fetching: fourflusher-2.0.1.gem (100%)
Successfully installed fourflusher-2.0.1
Fetching: xcodeproj-1.3.3.gem (100%)
ERROR:While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/xcodeproj
瞬間懵逼,不是說好的可以的嗎?怎么還出錯(cuò),于是自行百度,需要修改下命令,其實(shí)就是放到安裝目錄下去
$ sudo gem install -n /usr/local/bin cocoapods
此刻執(zhí)行完后會(huì)出現(xiàn)
Successfully installed xcodeproj-1.3.3
Fetching: molinillo-0.5.1.gem (100%)
Successfully installed molinillo-0.5.1
Fetching: cocoapods-trunk-1.1.1.gem (100%)
Successfully installed cocoapods-trunk-1.1.1
Fetching: cocoapods-downloader-1.1.2.gem (100%)
Successfully installed cocoapods-downloader-1.1.2
Fetching: cocoapods-deintegrate-1.0.1.gem (100%)
Successfully installed cocoapods-deintegrate-1.0.1
Fetching: cocoapods-core-1.1.1.gem (100%)
Successfully installed cocoapods-core-1.1.1
Fetching: cocoapods-1.1.1.gem (100%)
Successfully installed cocoapods-1.1.1
Parsing documentation for xcodeproj-1.3.3
Installing ri documentation for xcodeproj-1.3.3
Parsing documentation for molinillo-0.5.1
Installing ri documentation for molinillo-0.5.1
Parsing documentation for cocoapods-trunk-1.1.1
Installing ri documentation for cocoapods-trunk-1.1.1
Parsing documentation for cocoapods-downloader-1.1.2
Installing ri documentation for cocoapods-downloader-1.1.2
Parsing documentation for cocoapods-deintegrate-1.0.1
Installing ri documentation for cocoapods-deintegrate-1.0.1
Parsing documentation for cocoapods-core-1.1.1
Installing ri documentation for cocoapods-core-1.1.1
Parsing documentation for cocoapods-1.1.1
Installing ri documentation for cocoapods-1.1.1
7 gems installed
此時(shí)安裝成功了,趕快去試試你的cocoapods吧
$ pod search AFN(搜索AFN)就會(huì)出現(xiàn)很多相關(guān)的第三方庫。
是否解決了你的問題了呢?有的話就留言吧!??