CocoaPods安裝教程


標簽:

雖然網上關於CocoaPods安裝教程多不勝數,但是我在安裝的過程中還是出現了很多錯誤,所以大家可以照下來步驟裝一下,我相信會很好用.

前言

在iOS項目中使用第三方類庫可以說是非常常見的事,但是要正確地配置他們有時候是非常繁瑣的事情,幸運的是CocoaPods是一個很好的解決方案。

什么是CocoaPods

CocoaPods是OS X和iOS下的一個第三類庫管理工具,通過CocoaPods工具我們可以為項目添加被稱為“Pods”的依賴庫(這些類庫必須是CocoaPods本身所支持的),並且可以輕松管理其版本。

Cocoapods意義體現在兩個方面。第一,在引入第三方庫時它可以自動為我們完成各種各樣的配置,包括配置編譯階段、連接器選項、甚至是ARC環境下的-fno-objc-arc配置等。第二,使用CocoaPods可以很方便地查找新的第三方庫,這些類庫是比較“標准的”,而不是網上隨便找到的,這樣可以讓我們找到真正好用的類庫。

接下來我們將介紹CocoaPods的使用。

CocoaPods的核心組件

CocoaPods是用Ruby寫的,並划分成了若干個Gem包。

CocoaPods在解析執行過程中最重要的幾個包的路徑分別是:CocoaPods/CocoaPods、 CocoaPods/Core和 CocoaPods/Xcodeproj。

CocoaPods / CocoaPod:這是面向用戶的組件,每當執行一個pod命令時,這個組件將被激活。它包括了所有實用CocoaPods的功能,並且還能調用其他gem包來執行任務。

CocoaPods / Core:Core gem提供了與CocoaPods相關的文件(主要是podfile和podspecs)的處理。

Podfile:該文件用於配置項目所需要的第三方庫,它可以被高度定制。本文中我們主要在這里做動作。

Podspec:該文件描述了一個庫將怎樣被添加進工程中。.podspec文件可以標識該第三方庫所需要的源碼文件、依賴庫、編譯選項,以及其他第三方庫需要的配置。

CocoaPods / Xcodeproj:這個包負責處理工程文件,它能創建以及修改.xcodeproj文件和.xcworkspace文件。它也可以作為一個獨立的包使用,當你要編寫修改項目文件的腳本時,可以考慮使用CocoaPods/Xcodeproj。

Cocoapods安裝步驟

1、升級Ruby環境

終端輸入:$gem update –system

此時會出現

ERROR: While executing gem … (Gem::FilePermissionError)

You don‘t have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

zijingMacBook-Pro:~ shiyunlei$ sudo gem update —system

這個是因為你沒有權限去更新Ruby

這個時候你可以在終端使用:$sudo gem update —system來進行升級

img點擊並拖拽以移動

這個時候表示Ruby升級完成。

2、安裝CocoaPods時我們要訪問cocoapods.org,該網站可能被我們大天朝牆了,這樣下載安裝可能會是龜速,幸好我們可以用淘寶的Ruby鏡像來訪問該網站,方法如下:

1、gem sources –remove https://rubygems.org/

2、gem sources -a http://ruby.taobao.org/或者

1
gem source -a https://gems.ruby-china.com

最新版的Xcode要將http 換成 https

可以使用下面的命令(紅色部分)查看是否更換鏡像成功(如下圖所示):
$ gem sources -l

img點擊並拖拽以移動

3、安裝Cocoapods,在終端輸入命令

$sudo gem install cocoapods

這個時候會提示你輸入密碼,注:在終端輸入密碼不會有提示,光標也不會移動,一定要注意

開始安裝,如下圖:PS:這個過程可能花費時間比較長

img點擊並拖拽以移動

安裝成功如下:

img點擊並拖拽以移動

如果出現:

ERROR: While executing gem … (Errno::EPERM)

​ Operation not permitted - /usr/bin/xcodeproj

可以試試這個命令sudo gem install -n /usr/local/bin cocoapods

如果一切正常,你應該能看到一段安裝進度,以及最后有一條信息:

1
3 gems installed

點擊並拖拽以移動

  確認看見這條信息,后先判斷的CocoaPods是否可以使用,可以用CocoaPods的搜索功能驗證一下。在終端中輸入:

​ pod search AFNetworking;

執行后可能會一直停在

Setting up CocoaPods master repo然后(很久)會出現如下錯誤:

img點擊並拖拽以移動

解決辦法是:

這說明CocoaPods還不能正常使用,需要更新pod,下載它的一些依賴包;在終端中輸入:

1
2
   $ pod setup
過一段時間之后,你會在終端中看到跟上面同樣的紅色的錯誤信息。

這說明某些環境原因導致pod更新不了,可能原因有,1)gem版本太低;2)github無法鏈接;3).cocoapods目錄下的配置信息錯誤。我們可以一個一個來排除,

首先更新gem到最新版本,在終端中輸入:

1
$ sudo gem update --system

點擊並拖拽以移動

然后檢查是否可以ping通github,在終端中輸入:

1
$ ping github.com

點擊並拖拽以移動

然后查看pob repo list:

1
$ pod repo list

點擊並拖拽以移動

說明Cocoapods在將它的信息下載到 ~/.cocoapods里;

cd 到該目錄里,用du -sh *命令來查看文件大小,結果顯示0 repos,說明沒有安裝成功;

在終端輸入:

cd ~/.cocoapods

進入cocoapods文件后在終端輸入:du -sh *

img點擊並拖拽以移動

重新執行pod setup,過一段時間后提示setup completed,在終端中輸入 pod list,展示出安裝列表;

這樣總算安裝好了。接下來再一次輸入:

pod search AFNetworking

輸入過后它可能會報:

[!] Unable to find a pod with name, author, summary, or descriptionmatching AFNetworking

解決方案是:

輸入:

rm ~/Library/Caches/CocoaPods/search_index.json

后在一次輸入:pod search AFNetworking

就可以咯。

4、使用search命令搜索類庫名:

$pod search AFNetworking

如果CocoaPods支持,將會輸出搜索到的所有類庫版本和信息,以及在Podfile中配置的寫法,終端返回信息如下:

-> AFNetworking (2.3.1)

A delightful iOS and OS X networking framework.

pod ‘AFNetworking‘, ‘~> 2.3.1’(這個語句是需要在編輯Podfile的時候輸入的命令,即是如何安裝下載相關類庫的指令)

- Homepage: https://github.com/AFNetworking/AFNetworking

- Source: https://github.com/AFNetworking/AFNetworking.git

- Versions: 2.3.1, 2.3.0, 2.2.4, 2.2.3, 2.2.2, 2.2.1, 2.2.0, 2.1.0,

2.0.3, 2.0.2, 2.0.1, 2.0.0, 2.0.0-RC3, 2.0.0-RC2, 2.0.0-RC1, 1.3.4, 1.3.3,

1.3.2, 1.3.1, 1.3.0, 1.2.1, 1.2.0, 1.1.0, 1.0.1, 1.0, 1.0RC3, 1.0RC2, 1.0RC1,

0.10.1, 0.10.0, 0.9.2, 0.9.1, 0.9.0, 0.7.0, 0.5.1 [master repo]

- Sub specs: - AFNetworking/Serialization (2.3.1) -

AFNetworking/Security (2.3.1) - AFNetworking/Reachability (2.3.1) -

AFNetworking/NSURLConnection (2.3.1) - AFNetworking/NSURLSession (2.3.1)

- AFNetworking/UIKit (2.3.1)

-> AFNetworking+AutoRetry (0.0.5)

Auto Retries for AFNetworking requests

pod ‘AFNetworking+AutoRetry‘, ‘~> 0.0.5‘

- Homepage: https://github.com/shaioz/AFNetworking-AutoRetry

- Source: https://github.com/shaioz/AFNetworking-AutoRetry.git

- Versions: 0.0.5, 0.0.4, 0.0.3, 0.0.2, 0.0.1 [master repo]

二.cocoapods的使用

首先來到你的項目文件:

 cd 項目文件的位置

使用命令:

$cd /Users/AaronLee/Desktop/CocoapodsSample(進入工程目錄,cd后面的是工程的路徑)

$ touch Podfile(創建Podfile文件)

然后使用vim編輯Podfile文件,使用命令:

$ vim Podfile

然后緊接着按鍵盤上的“i”鍵,變成如下狀態,這個時候可以對Podfile文件進行編輯:

platform:ios, ‘7.0‘

pod ‘AFNetworking‘, ‘~> 2.3.1‘

在編輯完成后按“esc”,

img點擊並拖拽以移動

在按“:”,這個時候輸入wq,點擊回車,保存並退出。

img點擊並拖拽以移動

然后在終端輸入命令安裝相應的第三方類庫

$pod install 如果長時間沒有反應 證明被牆了 換成pod install –verbose –no-repo-update這個命令

因為這個過程需要下載相應的類庫,所以時間和網速有關。

注意百度上很多舊版本輸入的類容:

1
2
3
4
platform :ios, '8.1'
pod 'AFNetworking', '~> 2.0'
它會報:[!] The dependency `AFNetworking (~> 3.0)` is not used in any concrete target.
現在版本升級官方給的文檔是:

點擊並拖拽以移動

platform :ios, ‘8.0’

target ‘你的項目名稱’ do

pod ‘AFNetworking’, ‘~> 3.0’

end

輸入完成后按ESC退出編輯模式,最后輸入:wq保存並退出文件。此時可以發現在項目目錄下多了一個Podfile的文件,請注意這個文件必須與.xcodeproj在同一目錄下。

最后:

pod install

沒報錯就可以了。

如果遇到:

[!] Pods written in Swift can only be integrated as frameworks; add use_frameworks! to your Podfile or target to opt into using it. The Swift Pods being used are: Alamofire and SwiftyJSON

錯誤改成

platform :ios, “8.0”

use_frameworks!

target ‘Project’ do

pod ‘Alamofire’

pod ‘SwiftyJSON’

pod ‘SDWebImage’

end

就OK了

這個時候會看到之后打開工程都需要從類型為工程名.xcworkspace文件打開。

cocoapods:常見錯誤總結

1.無論是執行pod install還是pod update都卡在了Analyzing dependencies 或者 Updating local specs repositories不動
解決: 原因在於當執行以上兩個命令的時候會升級CocoaPods的spec倉庫,加一個參數可以省略這一步,然后速度就會提升不少。加參數的命令如下:

1
<code class="hljs brainfuck has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">pod</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">install</span> <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">verbose</span> <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">no</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">repo</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">update</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">pod</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">update</span> <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">verbose</span> <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">no</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">repo</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">update</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

點擊並拖拽以移動

2.pod 命令運行報下面錯誤

Your Podfile has had smart quotes sanitised. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes in your editor of choice.

解決: 不要使用文本編輯去編輯Podfile,使用Xcode編輯,或者使用終端敲命令去編輯。或者輸入格式錯誤,沒輸入運行版本:

1
<code class="hljs livecodeserver has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">platform</span>:iOS, <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">'7.0'</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

點擊並拖拽以移動

3.使用cocoapods導入第三方類庫后頭文件沒有代碼提示
解決: 選擇Target -> Build Settings 菜單,找到”User Header Search Paths”設置項,新增一個值"${SRCROOT}",並且選擇”Recursive”

4.The dependency “ is not used in any concrete target.
解決: 這個錯誤是說明你沒有使用下面的格式, 將 Podfile編輯成下面的格式

1
<code class="hljs r has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"> platform :ios,<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">'7.0'</span> target <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">'你的app的target名字'</span> do pod <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">'AFNetworking'</span>, <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">'2.0'</span> pod <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">'SDWebImage'</span>, <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">'3.7'</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">...</span> end </code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li></ul>

點擊並拖拽以移動

5.安裝錯誤

Setting up CocoaPods master repo
[!] /usr/bin/Git clone https://github.com/CocoaPods/Specs.git master –depth=1
Cloning into ‘master’…
error: RPC failed; result=18, HTTP code = 200
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

解決:

1
<code class="hljs brainfuck has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">$</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">git</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">config</span> <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">global</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">http</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">.</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">postBuffer</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">24288000</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">$</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">git</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">config</span> <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">list</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

點擊並拖拽以移動

若輸出 http.postbuffer=24288000, 就 OK了

6.在 pod install 時, 可以生成要導入的第三庫, 但是其頭文件找不到, 文件有缺失, target 設置沒有完成.

1
<code class="hljs asciidoc has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">[!] The <span class="hljs-smartquote" style="box-sizing: border-box;">`Paopao [Debug]` target overrides the `PODS_ROOT` build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig'</span>. This can lead to problems with the CocoaPods installation <span class="hljs-bullet" style="box-sizing: border-box;">- </span>Use the <span class="hljs-code" style="box-sizing: border-box;">`$(inherited)`</span> flag, or <span class="hljs-bullet" style="box-sizing: border-box;">- </span>Remove the build settings from the target. [!] The <span class="hljs-smartquote" style="box-sizing: border-box;">`Paopao [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig'</span>. This can lead to problems with the CocoaPods installation <span class="hljs-bullet" style="box-sizing: border-box;">- </span>Use the <span class="hljs-code" style="box-sizing: border-box;">`$(inherited)`</span> flag, or <span class="hljs-bullet" style="box-sizing: border-box;">- </span>Remove the build settings from the target. [!] The <span class="hljs-smartquote" style="box-sizing: border-box;">`Paopao [Release]` target overrides the `PODS_ROOT` build setting defined in `Pods/Target Support Files/Pods/Pods.release.xcconfig'</span>. This can lead to problems with the CocoaPods installation <span class="hljs-bullet" style="box-sizing: border-box;">- </span>Use the <span class="hljs-code" style="box-sizing: border-box;">`$(inherited)`</span> flag, or <span class="hljs-bullet" style="box-sizing: border-box;">- </span>Remove the build settings from the target. [!] The <span class="hljs-smartquote" style="box-sizing: border-box;">`Paopao [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods/Pods.release.xcconfig'</span>. This can lead to problems with the CocoaPods installation <span class="hljs-bullet" style="box-sizing: border-box;">- </span>Use the <span class="hljs-code" style="box-sizing: border-box;">`$(inherited)`</span> flag, or <span class="hljs-bullet" style="box-sizing: border-box;">- </span>Remove the build settings from the target.</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li></ul>

點擊並拖拽以移動

解決: 產生此警告的原因是項目 Target 中的一些設置,CocoaPods 也做了默認的設置,如果兩個設置結果不一致,就會造成問題。
我想要使用 CocoaPods 中的設置,分別在我的項目中定義PODS_ROOTOther Linker Flags的地方,把他們的值用$(inherited)替換掉,進入終端,執行 pod update , 然后錯誤沒了.

還有一種簡單粗暴的方法:
點擊項目文件 project.xcodeproj,右鍵顯示包內容,用文本編輯器打開project.pbxproj,刪除OTHER_LDFLAGS的地方,保存,執行pod update,錯誤沒了

7.引用要導入的三方庫缺少 .o 文件的錯誤
這里寫圖片描述點擊並拖拽以移動

解決: 在Build Setting 中的Other Linker Flags選項中加入$(OTHER_LDFLAGS)

8.還有一個復雜些的錯誤, 在為新項目配置 cocoapods 時遇到的

1
<code class="hljs lasso has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Co 大專欄  CocoaPods安裝教程de Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">LoadError <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">-</span> dlopen(/Users/MyMac<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">/</span><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>rvm/rubies/ruby<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">-</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2.0</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.0</span><span class="hljs-attribute" style="box-sizing: border-box;">-p643</span>/lib/ruby/<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2.0</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.0</span>/x86_64<span class="hljs-attribute" style="box-sizing: border-box;">-darwin14</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.1</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.0</span>/psych<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>bundle, <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">9</span>): Library <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">not</span> loaded: /usr/<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">local</span>/lib/libyaml<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">-</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.2</span><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>dylib Referenced from: /Users/MyMac<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">/</span><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>rvm/rubies/ruby<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">-</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2.0</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.0</span><span class="hljs-attribute" style="box-sizing: border-box;">-p643</span>/lib/ruby/<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2.0</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.0</span>/x86_64<span class="hljs-attribute" style="box-sizing: border-box;">-darwin14</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.1</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.0</span>/psych<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>bundle Reason: image <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">not</span> found <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">-</span> /Users/MyMac<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">/</span><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>rvm/rubies/ruby<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">-</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2.0</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.0</span><span class="hljs-attribute" style="box-sizing: border-box;">-p643</span>/lib/ruby/<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2.0</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.0</span>/x86_64<span class="hljs-attribute" style="box-sizing: border-box;">-darwin14</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.1</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.0</span>/psych<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>bundle</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul>

點擊並拖拽以移動

9.Mac OS X 跟新到10.11后cocoapods安裝出現的問題

$ sudo gem install cocoapods
ERROR: Could not find a valid gem ‘cocoapods’ (>= 0), here is why:
Unable to download data from http://ruby.taobao.org/ - bad response Not Found 404 (http://ruby.taobao.org/latest_specs.4.8.gz)

更新ruby后也沒有解決, 最后發現是由於淘寶鏡像失效了,http://ruby.taobao.org/失效了
解決方案有兩個:
1>將淘寶鏡像的http改為https

1
<code class="hljs ruby has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>gem sources --remove <span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">http:</span>/<span class="hljs-regexp" style="color: rgb(0, 136, 0); box-sizing: border-box;">/ruby.taobao.org/</span> <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>gem sources -a <span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">https:</span>/<span class="hljs-regexp" style="color: rgb(0, 136, 0); box-sizing: border-box;">/ruby.taobao.org/</span> <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>gem sources -l</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul>

點擊並拖拽以移動

再安裝就可以了

1
<code class="hljs bash has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">$ <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> gem install cocoapods</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

點擊並拖拽以移動

2>后來在stackoverflow上看到一個回答 是關於gem install fails with openssl failure,將淘寶鏡像替換為http://rubygems.org/.

1
<code class="hljs bash has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">$ gem <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">source</span> <span class="hljs-operator" style="box-sizing: border-box;">-a</span> http://rubygems.org/</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

點擊並拖拽以移動

再安裝就可以了

1
<code class="hljs bash has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">$ <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> gem install cocoapods</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

點擊並拖拽以移動

10.ruby環境需要升級更新
ERROR: Error installing cocoapods: activesupport requires Ruby version >= 2.2.2.

原因:在安裝cocoapods過程中提示需要Ruby的版本在2.2.2以上,而目前使用的Ruby版本是Mac系統自帶的1.8.7。所以需要對Ruby進行升級。以下是安裝Ruby的三種方法:
1.下載ruby源代碼,編譯,安裝
2.使用發行版自帶的安裝包,安裝
3.使用 rvm安裝
在這里還是推薦大家通過rvm對Ruby進行升級,具體的步驟這里就不贅述了, 需要的請查看我的博客之 cocoapods:安裝/更新Ruby環境教程, 里面有通過ram安裝ruby的具體操作.

11.pod setup/ pod install 錯誤總結

問題1:

$ pod install
Analyzing dependencies
[!] Unable to satisfy the following requirements:
-AFNetworking (~> 3.0) required by Podfile
None of your spec sources contain a spec satisfying the dependency: AFNetworking (~> 3.0).
You have either:

  • out-of-date source repos which you can update with pod repo update.
  • mistyped the name or version.
  • not added the source repo that hosts the Podspec to your Podfile.
    Note: as of CocoaPods 1.0, pod repo update does not happen on pod install by default.

解決:

1
<code class="hljs smalltalk has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span class="hljs-char" style="box-sizing: border-box;">$ </span>pod repo remove master <span class="hljs-char" style="box-sizing: border-box;">$ </span>pod repo add master <span class="hljs-method" style="box-sizing: border-box;">https:</span>//gitcafe.com/akuandev/<span class="hljs-class" style="box-sizing: border-box; color: rgb(102, 0, 102);">Specs</span>.git <span class="hljs-char" style="box-sizing: border-box;">$ </span>pod repo update</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul>

點擊並拖拽以移動

問題2:

$ 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 -36
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
解決:

1
<code class="hljs cs has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">$ sudo xcode-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">select</span> -<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">switch</span> /Applications/Xcode.app/Contents/Developer</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

點擊並拖拽以移動

並一定是這行代碼,要根據自己的情況,來修改這個命令行, 也許你是多個xcode, 那么你的命令行就要修改一下:

1
<code class="hljs cs has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">$ sudo xcode-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">select</span> -<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">switch</span> /Applications/Xcode <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7.3</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.1</span>.app/Contents/Developer</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

點擊並拖拽以移動

問題3:

$ 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

問題4:

$ 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 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

這些怎么解決呢? 其實mac OS 10.11之后, cocoapods的一些命令需要進行變化,今天來總結一下. 如果你遇到了pod setup或者pod update 的問題了, 而且很難解決, 我建議不如卸載重裝. 10.11 之后, 安裝cocoapods有一些不同的命令,下面總結一下:
1.檢查ruby環境,若需要請按如下更新

1
<code class="hljs bash has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">$ <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> gem update --system</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

點擊並拖拽以移動

2.卸載cocoapods

1
<code class="hljs bash has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">$ <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> gem uninstall cocoapods</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

點擊並拖拽以移動

3.重裝cocoapods (安裝命令有變化)
10.11之前

1
<code class="hljs bash has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">$ <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> gem install cocoapods</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

點擊並拖拽以移動

10.11之后

1
<code class="hljs lasso has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">$ sudo gem install <span class="hljs-attribute" style="box-sizing: border-box;">-n</span> /usr/<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">local</span>/bin cocoa pods</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

點擊並拖拽以移動

4.

1
<code class="hljs lasso has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">$ sudo chmod <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">+</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">rx</span> /usr/<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">local</span>/bin $ sudo xcode<span class="hljs-attribute" style="box-sizing: border-box;">-select</span> <span class="hljs-attribute" style="box-sizing: border-box;">-switch</span> /Applications/Xcode<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>app/Contents/Developer</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

點擊並拖拽以移動

//將 CocoaPods Specs repository復制到你電腦上~/.cocoapods目錄下

1
<code class="hljs has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">pod setup</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

點擊並拖拽以移動

解決方案可以參考 cocoapods:為新項目添加第三方類庫時出錯
參考文章: http://www.jianshu.com/p/b5315bf42975


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM