CocoaPods新版使用,遇到的那些坑剑梳!(Markdown版)

聲明:首先網(wǎng)上找到的這個是可以用的,我只是整理一下方便統(tǒng)一查閱锨咙。讓遇到問題的朋友追逮,看著一篇文章就夠了粹舵,不用再去東找西找解決問題了骂倘。

如果你遇到啦env: ruby_executable_hooks: No such file or directory這個問題粗暴點重新按著步驟安裝一下好了。

一稠茂、第一部分新版安裝

** 最新版 CocoaPods 的安裝流程**

1.移除現(xiàn)有Ruby默認源
$gem sources --remove https://rubygems.org/
2.使用新的源
$gem sources -a https://ruby.taobao.org/
3.驗證新源是否替換成功
$gem sources -l
4.安裝CocoaPods
(1) $sudo gem install cocoapods 備注:蘋果系統(tǒng)升級 OS X EL Capitan 后改為$sudo gem install -n /usr/local/bin cocoapods
(2) $pod setup
(3)$pod --version 查看CocoaPods版本
5.更新gem
$sudo gem update --system
6. 新建工程,并在終端用cd指令到文件夾內(nèi)
$pod search 第三方
7.新建文件 vim “Podfile”,
$vim Podfile
寫入以下內(nèi)容并保存 小提示:(終端vim文件 按 i 可編輯 毡证,esc 退出編輯,:wq  可保存退出)
platform:ios, '6.0'
pod 'AFNetworking', '~> 2.3.1'    <-------第三方
8.導(dǎo)入第三方庫
$pod install
9.退出終端

使用 pod install 還是 pod update 區(qū)別

二丐箩、安裝使用過程中遇到的一些錯誤恤煞!總結(jié):

終端 cocoapods 下載bug調(diào)試:

錯誤1:

Error fetching[http://ruby.taobao.org/:](http://ruby.taobao.org/:)
bad response Not Found 404 ([http://ruby.taobao.org/specs.4.8.gz](http://ruby.taobao.org/specs.4.8.gz))
解決方案:把安裝流程中
 $gem sources -a[http://ruby.taobao.org/](http://ruby.taobao.org/)---改為---->$gem sources -a[https://ruby.taobao.org/](https://ruby.taobao.org/)

錯誤2:

ERROR:  While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/pod
解決方案:蘋果系統(tǒng)升級OS X EL Capitan后會出現(xiàn)的插件錯誤,將安裝流程 4.安裝CocoaPods 的 (1)sudo gem install cocoapods ——>改為sudo gem install -n /usr/local/bin cocoapods

錯誤3:

[!] Unable to satisfy the following requirements: - `AVOSCloud (~> 3.1.6.3)` required by `Podfile`
Specs satisfying the `AVOSCloud (~> 3.1.6.3)` dependency were found, but they required a higher minimum deployment target.
解決方案:安裝流程:Podfile文件 中  platform:ios, ‘6.0’  后邊的 6.0 是平臺版本號 概漱,一定要加上
同樣朋友們也可以看這位筆友寫的:CocoaPods的安裝使用和常見問題http://www.reibang.com/p/6e5c0f78200a

錯誤4:

安裝第三方庫遇到的錯誤.png

這個問題解決可以點擊這里
*** 如果那個連接上面寫的不明確就照這個來:***
出錯原因:podfile升級之后到最新版本喜喂,pod里的內(nèi)容必須明確指出所用第三方庫的target,否則會出現(xiàn)The dependency `` is not used in any concrete target這樣的錯誤照弥。:

以下從三個步驟陳述:

Podfile升級

1进副、查看pod版本:pod --version
2、pod 升級(此時是升級到1.0.0.beta.2版本):sudo gem install cocoapods --pre

錯誤內(nèi)容:

如果你的Podfile的內(nèi)容是:

如果你的Podfile的內(nèi)容是.png

pod install 后出現(xiàn)錯誤 The dependency `` is not used in any concrete target
出現(xiàn)錯誤.png

修改方法:注意 target 要換成你自己的target
Podfile內(nèi)容更改.png

錯誤5:

如果你也和我一樣遇到啦這個問題:library not found for -lPods-AFNetworking

恭喜你了:問題現(xiàn)在解決了就是這個樣:
是因為 cocoapods 升級后格式變了给赞,
從某個版本開始鸥昏, 在 builldsetting -> other linker flags 把-lPods-AFNetworking改成-l"AFNetworking", 其他的一樣。 
你先把所有的庫移除掉再重新 pod install 也可以

錯誤6:

**Error installing cocoapods: activesupport requires Ruby version >= 2.2.2.
**

解決方案
安裝 RVM baby 版本管理器

$curl -L get.rvm.io | bash -s stable

等安裝完成 出現(xiàn)下面這行提示以下

Incaseofproblems:https://rvm.io/helpandhttps://twitter.com/rvm_io

執(zhí)行

$source ~/.bashrc $source ~/.bash_profile

測試是否安裝正常

$rvm -v

提示以下

rvm 1.27.0 (latest) by Wayne E. Seguin, Michal Papis[https://rvm.io/]

用RVM升級Ruby查看當前ruby版本

$ruby -v $rvm list known

提示以下
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.8]
[ruby-]2.2[.4]
[ruby-]2.3[.0]
[ruby-]2.2-headruby-head
# for forks use: rvm install ruby-head---url https://github.com/github/ruby.git --branch 2.2
# JRuby
安裝ruby 2.2.2 執(zhí)行

$rvm install 2.2.2

如果打诱涎摹:
![www(http://upload-images.jianshu.io/upload_images/436736-cfad69fcfe1119f3.gif?imageMogr2/auto-orient/strip)
……  ruby-2.2.2-#validate archive
ruby-2.2.2-#extract
ruby-2.2.2-#validate binary
ruby-2.2.2-#setup
ruby-2.2.2- #gemset created /Users/abc/.rvm/gems/ruby-2.2.2@global
ruby-2.2.2- #importing gemset
/Users/abc/.rvm/gemsets/global.gems..............................
ruby-2.2.2- #generatingglobalwrappers........
ruby-2.2.2- #gemset created /Users/abc/.rvm/gems/ruby-2.2.2ruby-2.2.2- #importing gemsetfile /Users/abc/.rvm/gemsets/default.gems
evaluated to empty gem list    ruby-2.2.2- #generatingdefaultwrappers........
Updating certificatesin'/etc/openssl/cert.pem'.
mkdir:/etc/openssl: Permission denied
mkdir-p"/etc/openssl"failed, retrying with sudo
LiuWenqiang password requiredfor'mkdir -p /etc/openssl':
and sudo mkdir worked

![](http://upload-images.jianshu.io/upload_images/436736-e9b71ac6486db8a5.gif?imageMogr2/auto-orient/strip)
則說明安裝成功了
打印代碼:
![](http://upload-images.jianshu.io/upload_images/436736-6d3824c1c83ffcbd.gif?imageMogr2/auto-orient/strip)
Done with Command Line Tools (OS X10.11)forXcode
Done.==> /usr/bin/sudo /bin/rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress==>Installing the Command Line Tools (expect a GUI popup):==> /usr/bin/sudo /usr/bin/xcode-select --install
xcode-select: error: command line tools are already installed, use"Software Update"to install updates
Failed during:/usr/bin/sudo /usr/bin/xcode-select --install
Requirements installation failed with status:1.

![](http://upload-images.jianshu.io/upload_images/436736-f2d5eb0051219eff.gif?imageMogr2/auto-orient/strip)
繼續(xù)安裝 CocoaPods
$sudo gem install cocoa pods
$sudo gem install -n /usr/local/bin cocoapods
$pod setup
更新 gem

$sudo gem update --system

6.新建一個項目唯蝶,名字PodTest

錯誤7:

**[!]Pod::Executable clone'https://github.com/CocoaPods/Specs.git' master
xcrun: error: active developer path ("/Users/xiakejie/工具/Xcode 2.app/Contents/Developer") does not exist, use xcode-select to change**

解決上面這個問題,使用這個命令: sudo xcode-select-switch/Applications/Xcode.app/Contents/Developer

錯誤8:

**[!] Unable to satisfy the following requirements:**
**- `xxwnload (= 1.0.1)` required by `Podfile`**
**None of your spec sources contain a spec satisfying the dependency: `xxownload (= 1.0.1)`.**

解決上面這個問題,使用這個命令:pod setup或者pod update --verbose
耐心等一下需要的時間較長。

錯誤9:

Paste_Image.png
[!] Error installing Alamofire
[!]/usr/bin/gitclonehttps://github.com/Alamofire/Alamofire.git/var/folders/df/78n63m8s637ffyp78cclhtj00000gn/T/d20161010-1282-y78he1 --template= --single-branch --depth 1 --branch 4.0.0

解決方法:執(zhí)行sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer(-switch 后面加上你的Xcode.app包內(nèi)容里的Developer的文件夾路徑即可)

錯誤10:

**[!] /usr/bin/curl -f -L -o /var/folders/df/78n63m8s637ffyp78cclhtj00000gn/T/d20161010-1307-1x4n64o/file.zip https://d3e51fp79zp4el.cloudfront.net/library/ios/v5.6/helpshift-sdk-ios-v5.6.1.zip --create-dirs --netrc-optional
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
 56 36.4M   56 20.6M    0     0  22343      0  0:28:30  0:16:07  0:12:23     0curl: (56) SSLRead() return error -9806
**
66D148B1-E0AA-4989-8729-DC3F6F5DF2AE.png

解決方法:
錯誤原因:下載這個庫的時候超時了(超時的原因有很多但是這個的原因是):很簡單需要翻墻鼓蜒。 具體怎么翻作為猿我就不多說了應(yīng)該有很多征字。翻墻成功之后 pod install就搞定了。

錯誤11:

[!] /bin/bash -c 
set -e
sh build.sh cocoapods-setup

core is not a symlink. Deleting...
Downloading dependency: core 1.5.0
Downloading core failed:
curl: (56) SSLRead() return error -9806

解決方法: rm -rf Pods畅厢,刪除工程目錄下的pods文件夾氮昧,然后重新 pod install框杜,安裝Realm的時候會慢一些袖肥,等了很長時間...解決方 法 參考鏈接

curl https://static.realm.io/downloads/core/realm-core-0.96.0.tar.bz2 -O
mkdir $TMPDIR/core_bin
mv realm-core-0.96.0.tar.bz2 $TMPDIR/core_bin

錯誤12:

realm pod 報錯'object_schema.hpp' file not found

1. rm -rf Pods
2. rm -rf ~/Library/Caches/CocoaPods

錯誤13:

[!] The `test [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 `test [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.

解決方法:
產(chǎn)生此警告的原因是項目 Target 中的一些設(shè)置椎组,CocoaPods 也做了默認的設(shè)置油狂,如果兩個設(shè)置結(jié)果不一致庐杨,就會造成問題。
方法一:
我想要使用 CocoaPods 中的設(shè)置仁堪,分別在我的項目中定義PODS_ROOTOther Linker Flags的地方,把他們的值用$(inherited)替換掉弦聂,進入終端氛什,執(zhí)行:
pod install
方法二:
點擊項目文件 project.xcodeproj,右鍵顯示包內(nèi)容枪眉,用文本編輯器打開project.pbxproj,刪除OTHER_LDFLAGS的地方贸铜,保存聂受,回到 Xcode烤镐,編譯通過。
理論上就OK了炮叶。不過我還碰到這種情況類似,但解決路徑不一樣
相似錯誤:

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

[!] The `Swiot [Release]` target overrides the `HEADER_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods-Swiot/Pods-Swiot.release.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.
看我標紅的路徑.png

解決方法:就是分別在我的項目中
Build Settiongs->搜索HEADER_SEARCH_PATHS這個
地方祟辟,添加$(inherited)侣肄,進入終端,執(zhí)行:pod install
之后完美解決

錯誤14:

當執(zhí)行 pod install 時出現(xiàn)這個警告

[!] The version of CocoaPods used to generate the lockfile (1.2.1) is higher than the version of the current executable (1.1.1). Incompatibility issues may arise.

解決方法:1、執(zhí)行:pod repo update 命令更新資源庫被芳。
2、升級一下pod 執(zhí)行命令:sudo gem install cocoapods 備注:蘋果系統(tǒng)升級 OS X EL Capitan 后改為$sudo gem install -n /usr/local/bin cocoapods

                                              --------- By ZPengs
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末剩晴,一起剝皮案震驚了整個濱河市侵状,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌趣兄,老刑警劉巖,帶你破解...
    沈念sama閱讀 218,682評論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件艇潭,死亡現(xiàn)場離奇詭異,居然都是意外死亡鲁纠,警方通過查閱死者的電腦和手機鳍寂,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,277評論 3 395
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來迄汛,“玉大人骤视,你說我怎么就攤上這事白群。” “怎么了帜慢?”我有些...
    開封第一講書人閱讀 165,083評論 0 355
  • 文/不壞的土叔 我叫張陵,是天一觀的道長躬柬。 經(jīng)常有香客問我迫横,道長魂角,這世上最難降的妖魔是什么繁成? 我笑而不...
    開封第一講書人閱讀 58,763評論 1 295
  • 正文 為了忘掉前任拼卵,我火速辦了婚禮史汗,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘停撞。我一直安慰自己,他們只是感情好艰猬,可當我...
    茶點故事閱讀 67,785評論 6 392
  • 文/花漫 我一把揭開白布埋市。 她就那樣靜靜地躺著,像睡著了一般恐疲。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上培己,一...
    開封第一講書人閱讀 51,624評論 1 305
  • 那天省咨,我揣著相機與錄音肃弟,去河邊找鬼。 笑死穷缤,一個胖子當著我的面吹牛,可吹牛的內(nèi)容都是我干的津肛。 我是一名探鬼主播汗贫,決...
    沈念sama閱讀 40,358評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼落包!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起涯鲁,我...
    開封第一講書人閱讀 39,261評論 0 276
  • 序言:老撾萬榮一對情侶失蹤有序,失蹤者是張志新(化名)和其女友劉穎抹腿,沒想到半個月后旭寿,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,722評論 1 315
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,900評論 3 336
  • 正文 我和宋清朗相戀三年微渠,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片逞盆。...
    茶點故事閱讀 40,030評論 1 350
  • 序言:一個原本活蹦亂跳的男人離奇死亡松申,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出贸桶,到底是詐尸還是另有隱情,我是刑警寧澤皇筛,帶...
    沈念sama閱讀 35,737評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站旗笔,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏蝇恶。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,360評論 3 330
  • 文/蒙蒙 一潘懊、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧卦尊,春花似錦、人聲如沸岂却。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,941評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽揉燃。三九已至,卻和暖如春炊汤,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背姑曙。 一陣腳步聲響...
    開封第一講書人閱讀 33,057評論 1 270
  • 我被黑心中介騙來泰國打工迈倍, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人啼染。 一個月前我還...
    沈念sama閱讀 48,237評論 3 371
  • 正文 我出身青樓,卻偏偏與公主長得像迹鹅,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子逐样,可洞房花燭夜當晚...
    茶點故事閱讀 44,976評論 2 355

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