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

声明:首先网上找到的这个是可以用的,我只是整理一下方便统一查阅。让遇到问题的朋友,看着一篇文章就够了,不用再去东找西找解决问题了。

如果你遇到啦env: ruby_executable_hooks: No such file or directory这个问题粗暴点重新按着步骤安装一下好了。

一、第一部分新版安装

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

1.移除现有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 备注:苹果系统升级 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指令到文件夹内
$pod search 第三方
7.新建文件 vim “Podfile”,
$vim Podfile
写入以下内容并保存 小提示:(终端vim文件 按 i 可编辑 ,esc 退出编辑,:wq  可保存退出)
platform:ios, '6.0'
pod 'AFNetworking', '~> 2.3.1'    <-------第三方
8.导入第三方库
$pod install
9.退出终端

使用 pod install 还是 pod update 区别

二、安装使用过程中遇到的一些错误!总结:

终端 cocoapods 下载bug调试:

错误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
解决方案:苹果系统升级OS X EL Capitan后会出现的插件错误,将安装流程 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.jianshu.com/p/6e5c0f78200a

错误4:

安装第三方库遇到的错误.png

这个问题解决可以点击这里
*** 如果那个连接上面写的不明确就照这个来:***
出错原因:podfile升级之后到最新版本,pod里的内容必须明确指出所用第三方库的target,否则会出现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

错误内容:

如果你的Podfile的内容是:

如果你的Podfile的内容是.png

pod install 后出现错误 The dependency `` is not used in any concrete target
出现错误.png

修改方法:注意 target 要换成你自己的target
Podfile内容更改.png

错误5:

如果你也和我一样遇到啦这个问题:library not found for -lPods-AFNetworking

恭喜你了:问题现在解决了就是这个样:
是因为 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

等安装完成 出现下面这行提示以下

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

执行

$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 执行

$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)
继续安装 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

解决方法:执行sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer(-switch 后面加上你的Xcode.app包内容里的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

解决方法:
错误原因:下载这个库的时候超时了(超时的原因有很多但是这个的原因是):很简单需要翻墙。 具体怎么翻作为猿我就不多说了应该有很多。翻墙成功之后 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.

解决方法:
产生此警告的原因是项目 Target 中的一些设置,CocoaPods 也做了默认的设置,如果两个设置结果不一致,就会造成问题。
方法一:
我想要使用 CocoaPods 中的设置,分别在我的项目中定义PODS_ROOTOther Linker Flags的地方,把他们的值用$(inherited)替换掉,进入终端,执行:
pod install
方法二:
点击项目文件 project.xcodeproj,右键显示包内容,用文本编辑器打开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),进入终端,执行:pod install
之后完美解决

错误14:

当执行 pod install 时出现这个警告

[!] 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、执行:pod repo update 命令更新资源库。
2、升级一下pod 执行命令:sudo gem install cocoapods 备注:苹果系统升级 OS X EL Capitan 后改为$sudo gem install -n /usr/local/bin cocoapods

                                              --------- By ZPengs
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 151,511评论 1 330
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 64,495评论 1 273
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 101,595评论 0 225
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 42,558评论 0 190
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 50,715评论 3 270
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 39,672评论 1 192
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,112评论 2 291
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 29,837评论 0 181
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 33,417评论 0 228
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 29,928评论 2 232
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 31,316评论 1 242
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 27,773评论 2 234
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 32,253评论 3 220
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 25,827评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,440评论 0 180
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 34,523评论 2 249
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 34,583评论 2 249

推荐阅读更多精彩内容