聲明:首先網(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:
這個問題解決可以點擊這里
*** 如果那個連接上面寫的不明確就照這個來:***
出錯原因: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)容是:
pod install 后出現(xiàn)錯誤 The dependency `` is not used in any concrete target
修改方法:注意 target 要換成你自己的target
錯誤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:
[!] 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
**
解決方法:
錯誤原因:下載這個庫的時候超時了(超時的原因有很多但是這個的原因是):很簡單需要翻墻鼓蜒。 具體怎么翻作為猿我就不多說了應(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_ROOT
和 Other 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.
解決方法:就是分別在我的項目中
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