Cocoapods 常見(jiàn)錯(cuò)誤總結(jié)

1.無(wú)論是執(zhí)行pod install還是pod update都卡在了Analyzing dependencies 或者 Updating local specs repositories不動(dòng)
解決: 原因在于當(dāng)執(zhí)行以上兩個(gè)命令的時(shí)候會(huì)升級(jí)CocoaPods的spec倉(cāng)庫(kù)蠢护,加一個(gè)參數(shù)可以省略這一步瘦馍,然后速度就會(huì)提升不少。加參數(shù)的命令如下:

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

2.pod 命令運(yùn)行報(bào)下面錯(cuò)誤

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編輯煮嫌,或者使用終端敲命令去編輯器净〖馓裕或者輸入格式錯(cuò)誤惫叛,沒(méi)輸入運(yùn)行版本:

platform:iOS, '7.0'

3.使用cocoapods導(dǎo)入第三方類庫(kù)后頭文件沒(méi)有代碼提示
解決: 選擇Target -> Build Settings 菜單倡勇,找到\”User Header Search Paths\”設(shè)置項(xiàng),新增一個(gè)值"${SRCROOT}"嘉涌,并且選擇\”Recursive\”
4.The dependency “ is not used in any concrete target.
解決: 這個(gè)錯(cuò)誤是說(shuō)明你沒(méi)有使用下面的格式, 將 Podfile編輯成下面的格式

platform :ios,'7.0'
target '你的app的target名字' do
    pod 'AFNetworking', '2.0'
    pod 'SDWebImage', '3.7'
    ...
end     

5.安裝錯(cuò)誤

Setting up CocoaPods master repo [!] /usr/bin/git clone [https://github.com/CocoaPods/Specs.git](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

解決:

$ git config --global http.postBuffer 24288000
$ git config --list

若輸出 http.postbuffer=24288000, 就 OK了
6.在 pod install 時(shí), 可以生成要導(dǎo)入的第三庫(kù), 但是其頭文件找不到, 文件有缺失, target 設(shè)置沒(méi)有完成.

[!] The `Paopao [Debug]` target overrides the `PODS_ROOT` build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.

[!] The `Paopao [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.

[!] The `Paopao [Release]` target overrides the `PODS_ROOT` build setting defined in `Pods/Target Support Files/Pods/Pods.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.

[!] The `Paopao [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods/Pods.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.

解決: 產(chǎn)生此警告的原因是項(xiàng)目 Target 中的一些設(shè)置妻熊,CocoaPods 也做了默認(rèn)的設(shè)置,如果兩個(gè)設(shè)置結(jié)果不一致仑最,就會(huì)造成問(wèn)題扔役。
我想要使用 CocoaPods 中的設(shè)置,分別在我的項(xiàng)目中定義PODS_ROOT 和 Other Linker Flags的地方词身,把他們的值用$(inherited)替換掉厅目,進(jìn)入終端,執(zhí)行 pod update , 然后錯(cuò)誤沒(méi)了.

還有一種簡(jiǎn)單粗暴的方法:
點(diǎn)擊項(xiàng)目文件 project.xcodeproj法严,右鍵顯示包內(nèi)容损敷,用文本編輯器打開(kāi)project.pbxproj,刪除OTHER_LDFLAGS的地方深啤,保存拗馒,執(zhí)行pod update,錯(cuò)誤沒(méi)了
7.引用要導(dǎo)入的三方庫(kù)缺少 .o 文件的錯(cuò)誤

錯(cuò)誤截圖

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

8.還有一個(gè)復(fù)雜些的錯(cuò)誤, 在為新項(xiàng)目配置 cocoapods 時(shí)遇到的

LoadError - dlopen(/Users/MyMac/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/x86_64-darwin14.1.0/psych.bundle, 9): Library not loaded: /usr/local/lib/libyaml-0.2.dylib
  Referenced from: /Users/MyMac/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/x86_64-darwin14.1.0/psych.bundle
  Reason: image not found - /Users/MyMac/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/x86_64-darwin14.1.0/psych.bundle

9.Mac OS X 跟新到10.11后cocoapods安裝出現(xiàn)的問(wèn)題

$ 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/](http://ruby.taobao.org/) - bad response Not Found 404 ([http://ruby.taobao.org/latest_specs.4.8.gz](http://ruby.taobao.org/latest_specs.4.8.gz))

更新ruby后也沒(méi)有解決, 最后發(fā)現(xiàn)是由于淘寶鏡像失效了,http://ruby.taobao.org/失效了 解決方案有兩個(gè): 1>將淘寶鏡像的http改為https

$ gem sources --remove http://ruby.taobao.org/
$ gem sources -a https://ruby.taobao.org/
$ gem sources -l

再安裝就可以了

sudo gem install cocoapods

2>后來(lái)在stackoverflow上看到一個(gè)回答 是關(guān)于gem install fails with openssl failure,將淘寶鏡像替換為http://rubygems.org/.

$ gem source -a http://rubygems.org/

再安裝就可以了

$ sudo gem install cocoapods

10.ruby環(huán)境需要升級(jí)更新 ERROR: Error installing cocoapods: activesupport requires Ruby version >= 2.2.2.
原因:在安裝cocoapods過(guò)程中提示需要Ruby的版本在2.2.2以上,而目前使用的Ruby版本是Mac系統(tǒng)自帶的1.8.7溯街。所以需要對(duì)Ruby進(jìn)行升級(jí)诱桂。以下是安裝Ruby的三種方法: 1.下載ruby源代碼,編譯呈昔,安裝 2.使用發(fā)行版自帶的安裝包挥等,安裝 3.使用 rvm安裝 在這里還是推薦大家通過(guò)rvm對(duì)Ruby進(jìn)行升級(jí),具體的步驟這里就不贅述了, 需要的請(qǐng)查看我的博客之 cocoapods:安裝/更新Ruby環(huán)境教程, 里面有通過(guò)ram安裝ruby的具體操作.
11.pod setup/ pod install 錯(cuò)誤總結(jié)
問(wèn)題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.

解決:

$ pod repo remove master
$ pod repo add master https://gitcafe.com/akuandev/Specs.git
$ pod repo update

問(wèn)題2:

$ pod setup Setting up CocoaPods master repo [!] /usr/bin/git clone [https://github.com/CocoaPods/Specs.git](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 

解決:

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

并一定是這行代碼堤尾,要根據(jù)自己的情況肝劲,來(lái)修改這個(gè)命令行, 也許你是多個(gè)xcode, 那么你的命令行就要修改一下:

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

問(wèn)題3:

$ pod setup Setting up CocoaPods master repo [!] /usr/bin/git clone [https://github.com/CocoaPods/Specs.git](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

問(wèn)題4:

$ pod setup Setting up CocoaPods master repo [!] /usr/bin/git clone [https://github.com/CocoaPods/Specs.git](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

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

$ sudo gem update --system

2.卸載cocoapods

$ sudo gem uninstall cocoapods

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

$ sudo gem install cocoapods

10.11之后

$ sudo gem install -n /usr/local/bin cocoa pods
$ sudo chmod +rx /usr/local/bin
$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

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

pod setup

原文引自 http://blog.csdn.net/wangyanchang21/article/details/51437934

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子辞槐,更是在濱河造成了極大的恐慌掷漱,老刑警劉巖,帶你破解...
    沈念sama閱讀 221,273評(píng)論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件榄檬,死亡現(xiàn)場(chǎng)離奇詭異卜范,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)鹿榜,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,349評(píng)論 3 398
  • 文/潘曉璐 我一進(jìn)店門海雪,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人犬缨,你說(shuō)我怎么就攤上這事喳魏。” “怎么了怀薛?”我有些...
    開(kāi)封第一講書(shū)人閱讀 167,709評(píng)論 0 360
  • 文/不壞的土叔 我叫張陵刺彩,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我枝恋,道長(zhǎng)创倔,這世上最難降的妖魔是什么? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 59,520評(píng)論 1 296
  • 正文 為了忘掉前任焚碌,我火速辦了婚禮畦攘,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘十电。我一直安慰自己知押,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,515評(píng)論 6 397
  • 文/花漫 我一把揭開(kāi)白布鹃骂。 她就那樣靜靜地躺著台盯,像睡著了一般。 火紅的嫁衣襯著肌膚如雪畏线。 梳的紋絲不亂的頭發(fā)上静盅,一...
    開(kāi)封第一講書(shū)人閱讀 52,158評(píng)論 1 308
  • 那天,我揣著相機(jī)與錄音寝殴,去河邊找鬼蒿叠。 笑死,一個(gè)胖子當(dāng)著我的面吹牛蚣常,可吹牛的內(nèi)容都是我干的市咽。 我是一名探鬼主播,決...
    沈念sama閱讀 40,755評(píng)論 3 421
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼抵蚊,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼魂务!你這毒婦竟也來(lái)了曼验?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書(shū)人閱讀 39,660評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤粘姜,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后熔酷,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體孤紧,經(jīng)...
    沈念sama閱讀 46,203評(píng)論 1 319
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,287評(píng)論 3 340
  • 正文 我和宋清朗相戀三年拒秘,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了号显。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,427評(píng)論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡躺酒,死狀恐怖押蚤,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情羹应,我是刑警寧澤揽碘,帶...
    沈念sama閱讀 36,122評(píng)論 5 349
  • 正文 年R本政府宣布,位于F島的核電站园匹,受9級(jí)特大地震影響雳刺,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜裸违,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,801評(píng)論 3 333
  • 文/蒙蒙 一掖桦、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧供汛,春花似錦枪汪、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 32,272評(píng)論 0 23
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至朱监,卻和暖如春岸啡,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背赫编。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 33,393評(píng)論 1 272
  • 我被黑心中介騙來(lái)泰國(guó)打工巡蘸, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人擂送。 一個(gè)月前我還...
    沈念sama閱讀 48,808評(píng)論 3 376
  • 正文 我出身青樓悦荒,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親嘹吨。 傳聞我的和親對(duì)象是個(gè)殘疾皇子搬味,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,440評(píng)論 2 359

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

  • CocoaPods 是什么? CocoaPods 是一個(gè)負(fù)責(zé)管理 iOS 項(xiàng)目中第三方開(kāi)源庫(kù)的工具。CocoaPo...
    朝洋閱讀 25,693評(píng)論 3 51
  • 項(xiàng)目組件化碰纬、平臺(tái)化是技術(shù)公司的共同目標(biāo)萍聊,越來(lái)越多的技術(shù)公司推崇使用pod管理第三方庫(kù)以及私有組件,一方面使項(xiàng)目架構(gòu)...
    swu_luo閱讀 21,855評(píng)論 0 39
  • 一亭螟、CocoaPods 的卸載 有的時(shí)候我們需要降低Cocoapods的版本來(lái)解決第三方庫(kù)的兼容問(wèn)題. 1. 移除...
    小_夭閱讀 4,260評(píng)論 9 8
  • 已是連續(xù)第三個(gè)春節(jié)沒(méi)有回家過(guò)年,而是和爸媽一起出門旅行骑歹。走過(guò)風(fēng)雪中的文化古城太原预烙,見(jiàn)過(guò)驕陽(yáng)下的微笑之國(guó)泰國(guó),今年道媚,...
    湛予閱讀 781評(píng)論 1 4
  • 最近有需求要發(fā)布一套SDK扁掸,這套SDK有幾個(gè)要求: 帶有Activity和Fragment; 有網(wǎng)絡(luò)請(qǐng)求模塊衰琐; 有...
    不羈的木木閱讀 4,113評(píng)論 0 51