最新版 CocoaPods 的安装流程

来源:互联网 发布:nagios源码 编辑:程序博客网 时间:2024/05/18 18:44
OS 最新版 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 --pre备注:这是安装最新版cocoapods的命令,如果不是最新版可能会导致一些最新的第三方库更新或者下载失败。

(2) $pod setup需要等几分钟时间

5.更新gem

$sudo gem update --system

6. 新建工程,并在终端用cd指令到文件夹内

$pod search 第三方

7.根据自己的习惯的方法创建Podfile文件

(1)新建Podfile文件$ touch Podfile

(2)打开Podfile文件$ open -e Podfile

(3)编辑Podfile文件:

<code class="hljs livecodeserver has-numbering"><span class="hljs-built_in">platform</span> :ios, <span class="hljs-string">'9.0'</span>use_frameworks!target <span class="hljs-string">'MyApp'</span> <span class="hljs-built_in">do</span>  pod <span class="hljs-string">'AFNetworking'</span>, <span class="hljs-string">'~> <span>3.0.4</span>'</span>  pod <span class="hljs-string">'ORStackView'</span>, <span class="hljs-string">'~> 3.0'</span>  pod <span class="hljs-string">'SwiftyJSON'</span>, <span class="hljs-string">'~> 2.3'</span><span class="hljs-function"><span class="hljs-keyword">end</span></span></code>
里面的 MyApp 记得替换为自己工程里面的target

platform:ios, '9.0'    <-------platform:ios, ‘9.0’  ios是第三方库所支持的平台,后边的 9.0 是本第三方库支持的系统的最高版本号。

pod 'AFNetworking', '~> 3.0.4'    <-------第三方

8.导入第三方库

$pod install

9.退出终端

以下是我用以前的安装流程安装时出现的一些错误

终端  cocoapods 下载bug调试:

错误1:

Error fetching http://ruby.taobao.org/:

bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)

解决方案:把安装流程中 $gem sources -a http://ruby.taobao.org/   ---改为----> $gem sources -a 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, ‘9.0’ 。

10.备注:

如果在使用cocoapods时遇到了其他问题可以去cocoapods官网地址。

0 0