最详细的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来进行升级

 

这个时候表示Ruby升级完成。

 

2、安装CocoaPods时我们要访问cocoapods.org,该网站可能被我们大天朝墙了,这样下载安装可能会是龟速,幸好我们可以用淘宝的Ruby镜像来访问该网站,方法如下:

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

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

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

 

最新版的Xcode要将http 换成 https

可以使用下面的命令(红色部分)查看是否更换镜像成功(如下图所示):
$ gem sources -l

3、安装Cocoapods,在终端输入命令

$sudo gem install cocoapods

这个时候会提示你输入密码,注:在终端输入密码不会有提示,光标也不会移动,一定要注意

开始安装,如下图:PS:这个过程可能花费时间比较长

 

安装成功如下:

 

 如果出现:

 

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

    Operation not permitted - /usr/bin/xcodeproj

 

可以试试这个命令sudo gem install -n /usr/local/bin cocoapods

 

如果一切正常,你应该能看到一段安装进度,以及最后有一条信息:

3 gems installed

  确认看见这条信息,后先判断的CocoaPods是否可以使用,可以用CocoaPods的搜索功能验证一下。在终端中输入:

      pod search AFNetworking;

执行后可能会一直停在

Setting up CocoaPods master repo然后(很久)会出现如下错误:

解决办法是:

这说明CocoaPods还不能正常使用,需要更新pod,下载它的一些依赖包;在终端中输入:

   $ pod setup

过一段时间之后,你会在终端中看到跟上面同样的红色的错误信息。

这说明某些环境原因导致pod更新不了,可能原因有,1)gem版本太低;2)github无法链接;3).cocoapods目录下的配置信息错误。我们可以一个一个来排除,

首先更新gem到最新版本,在终端中输入:

$ sudo gem update --system 

然后检查是否可以ping通github,在终端中输入:

$ ping github.com 

然后查看pob repo list:

$ pod repo list

说明Cocoapods在将它的信息下载到 ~/.cocoapods里;

cd  到该目录里,用du -sh *命令来查看文件大小,结果显示0 repos,说明没有安装成功;

在终端输入:

cd ~/.cocoapods

进入cocoapods文件后在终端输入:du -sh *

 

重新执行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”,

 

在按“:”,这个时候输入wq,点击回车,保存并退出。

 

然后在终端输入命令安装相应的第三方类库

$pod install     如果长时间没有反应 证明被墙了 换成pod install --verbose --no-repo-update这个命令 

因为这个过程需要下载相应的类库,所以时间和网速有关。

 

注意百度上很多旧版本输入的类容:

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仓库,加一个参数可以省略这一步,然后速度就会提升不少。加参数的命令如下:

<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编辑,或者使用终端敲命令去编辑。或者输入格式错误,没输入运行版本:

<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编辑成下面的格式

<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

解决: 

<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 设置没有完成.

<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_ROOT 和 Other Linker Flags的地方,把他们的值用$(inherited)替换掉,进入终端,执行 pod update , 然后错误没了.

还有一种简单粗暴的方法: 
点击项目文件 project.xcodeproj,右键显示包内容,用文本编辑器打开project.pbxproj,删除OTHER_LDFLAGS的地方,保存,执行pod update,错误没了

7.引用要导入的三方库缺少 .o 文件的错误 
这里写图片描述

解决: 在Build Setting 中的Other Linker Flags选项中加入$(OTHER_LDFLAGS)

8.还有一个复杂些的错误, 在为新项目配置 cocoapods 时遇到的

<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;">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

<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>

再安装就可以了

<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/.

<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>

再安装就可以了

<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.

解决:

<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 
解决:

<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, 那么你的命令行就要修改一下:

<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环境,若需要请按如下更新

<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

<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之前

<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之后

<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.

<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目录下

<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

 

  • 0
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值