cocoapods的安裝以及不能使用命令問題

因?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)的第三方庫。

是否解決了你的問題了呢?有的話就留言吧!??


有些人在安裝成功后還是不能使用命令,會(huì)提示無此命令,這個(gè)時(shí)候,就可以去你安裝的目錄下看看是不是安裝成功,如果是的話,就在你安裝成功的路徑下試試命令,如果可以的話就應(yīng)該是你的環(huán)境變量出問題了,或者被你修改了,這個(gè)時(shí)候只要執(zhí)行這一句話就可以了:PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容