CocoaPods問題大全

1:軟件源的替換 ??

ruby 的軟件源( https://rubygems.org )使用的是亞馬遜的云服務(wù),所以自帶的需要翻墻,但我們可以使用如下代碼將官方的 ruby 源替換成國(guó)內(nèi)淘寶的源(https://ruby.taobao.org/ )或者是由 Ruby China 社區(qū)專注維護(hù)的這個(gè)源(https://gems.ruby-china.org/ )。(我在鏡像的時(shí)候開始用的是淘寶的,但會(huì)卡死,可能是不能用了,也可能是網(wǎng)速慢,在后面講“坑”的時(shí)候會(huì)說(shuō))。在這我用的是Ruby China 社區(qū)專注維護(hù)的這個(gè)源(https://gems.ruby-china.org/)。

1:*首先,執(zhí)行以下命令刪除原來(lái)的ruby源:gem sources --remove https://rubygems.org/

執(zhí)行命令后可在終端看見以下信息:https://rubygems.org/ removed from sources

*然后下一步添加你找到的可用的鏡像源(這里我沒有用淘寶的源:https://ruby.taobao.org/ ):gem sources -a https://gems.ruby-china.org/

*驗(yàn)證新源是否替換成功

gem sources -l

終端輸出:

*** CURRENT SOURCES ***

https://gems.ruby-china.org/

到此ruby 源替已經(jīng)換成國(guó)內(nèi)的源

2 ?開始安裝 CocoaPods

? 2 .1如果gem太老,可以嘗試用如下命令升級(jí)gem:sudo gem update --system 升級(jí)成功后會(huì)提示: Latest version currently installed. Aborting.

其他安裝過程在此省略,在終端輸入pod setup 時(shí)出現(xiàn)以下錯(cuò)誤

下載安裝CocoaPods

終端輸入:sudo gem install -n /usr/local/bin cocoapods

接下來(lái)進(jìn)行安裝,執(zhí)行:pod setup

Setting up CocoaPods master repo 這個(gè)狀態(tài)一段時(shí)間,是因?yàn)橐M(jìn)行下載安裝,而且目錄比較大,需要耐心等待一下.安裝成功后,你會(huì)看到:? setup completed

速度有些慢,耐心等待~~

{以查看下載進(jìn)度----

cd ~/.cocoapods/? ? ? (這就是進(jìn)入cocoa pods文件夾的代碼)

du -sh * }

這樣就下載安裝好了CocoaPods

注意注意!!!

第一次執(zhí)行pod setup時(shí)CocoaPods會(huì)將這些podspec索引文件更新到本地的~/.cocoapods目錄下,這個(gè)索引文件比較大,所以第一次更新時(shí)非常慢.友好人士在國(guó)內(nèi)的服務(wù)器建立了Cocoapods索引庫(kù)的鏡像,

所以執(zhí)行索引跟新操作時(shí)候會(huì)快很多.具體操作方法如下:

pod repo remove master

//coding 上有每日更新的,建議使用這個(gè)

pod repo add master https://git.coding.net/CocoaPods/Specs.git

//或者用oschina,但是https 好像有問題,一直是403,所以用ssh的方式,這里需要到官網(wǎng)去配置ssh key

pod repo add master https://git.oschina.net/akuandev/Specs.git

如果提示失敗或者setup不成功:

出現(xiàn) [!] To setup the master specs repo, please run pod setup.

git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master

pod setup? //務(wù)必在手動(dòng)下載代碼后執(zhí)行一次,執(zhí)行后 Setup completed

//在執(zhí)行

pod install --verbose --no-repo-update //避免去更新了

如果使用oschina 的 https Git clone不成功的話,建議到git.oschina.net中添加ssh key,換ssh方式下載源碼

git clone git@git.oschina.net:akuandev/Specs.git? ~/.cocoapods/repos/master


如果你覺得pod setup不好你也可以用這方法手動(dòng)下載

解決方案:首先通過終端cd到~/.cocoapods/repos下,在此目錄下,輸入終端命令:

git clone ‘https://github.com/CocoaPods/Specs.git’ master

剩下的就是漫長(zhǎng)的等待,文件比較大,可能花費(fèi)些時(shí)間,結(jié)果如下所示:

Cloning into ‘master’…

remote: Counting objects: 760233, done.

remote: Compressing objects: 100% (34/34), done.

remote: Total 760233 (delta 12), reused 0 (delta 0), pack-reused 760197

Receiving objects: 100% (760233/760233), 350.74 MiB | 44.00 KiB/s, done.

Resolving deltas: 100% (324910/324910), done.

Checking connectivity… done.

Checking out files: 100% (98969/98969), done.


注意注意:以下是中途可能出現(xiàn)的問題

1:error: RPC failed; curl 56 SSLRead() return error -9806(有可能有時(shí)候是你網(wǎng)絡(luò)不好,如果還不行就執(zhí)行后面解決方案) 解決方案如下

MacBook-Pro:$ pod setup

Setting up CocoaPods master repo

[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master

Cloning into 'master'...

error: RPC failed; curl 56 SSLRead() return error -9806

fatal: The remote end hung up unexpectedly

fatal: early EOF

fatal: index-pack failed

在終端依次執(zhí)行以下命令行

brew remove git

?brew remove curl

?brew install openssl

?brew install --with-openssl curl

?brew install --with-brewed-curl --with-brewed-openssl git

然后在pod setup從試

2:error RPC failed; curl 56 SSLRead() return error -36(問題)或者 ?Unable to add a source with url https://github.com/CocoaPods/Specs.git named master-1 . You can try adding it manually in ~/.cocoapods/repos or via pod repo add . 是由于安裝了多個(gè)Xcode導(dǎo)致路徑變了,

Cloning into'master'...

error: RPC failed; curl56SSLRead()returnerror -36

fatal: The remote end hung up unexpectedly

fatal: early EOF

fatal: index-pack failed# 用以下這個(gè)命令來(lái)能解決問題:

$ sudo gem uninstall cocoa pods //交互時(shí)選擇 y

$ pod repo remove master

# 然后重新安裝即可

pod setup

或者看下面

建議先看完,再操作

1、只有一個(gè)xcode的情況,打開終端,輸入以下命令:

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

2、多個(gè)xcode

需要修改命令:

sudo xcode-select -switch /Applications/Xcode 7.3.1.app/Contents/Developer

根據(jù)你默認(rèn)的xcode來(lái)修改在/Applications/和/Contents/Developer中間的app的名字,如果你默認(rèn)的是Xcode x.x.x.app,中間就要替換掉。

也可以在終端里輸入:

sudo xcode-select --print-path

輸出:

/Applications/Xcode.app/Contents/Developer

這步結(jié)束。

然后刪除repos目錄下master

sudo rm -fr ~/.cocoapods/repos/master

再執(zhí)行pod setup,等了一會(huì),成功了。

ps:?jiǎn)栴}還存在,把xcode全部卸載,只裝一個(gè)最新的。

打開用了pods的工程,執(zhí)行pod update,報(bào)錯(cuò)

[!] The dependency `FMDB (~>2.3)`isnotusedinany concrete target.等等

網(wǎng)上找到答案,修改Podfile格式(這里就不做這方面的解釋了)

pod install --verbose --no-repo-update

pod update --verbose --no-repo-update

pod install與pod update區(qū)別:

1.使用pod install來(lái)安裝新的庫(kù),即使你的工程里面已經(jīng)有了Podfile,并且已經(jīng)執(zhí)行過pod install命令了;所以即使你是添加或移除庫(kù),都應(yīng)該使用pod install。

2.使用pod update [PODNAME] 只有在你需要更新庫(kù)到更新的版本時(shí)候用。

如果還遇見了其它方面的問題,歡迎加入608099662群進(jìn)行交流

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

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