您的位置:首页 > 运维架构

CocoaPods安装和使用教程

2015-04-13 20:48 204 查看
1. 安装gem

$ gem sources --remove https://rubygems.org/ //等有反应之后再敲入以下命令
$ gem sources -a http://ruby.taobao.org/[/code] 2.为了验证你的Ruby镜像是并且仅是taobao,可以用以下命令查看:

$ gem sources -l

3.只有在终端中出现下面文字才表明你上面的命令是成功的:

*** CURRENT SOURCES ***
 http://ruby.taobao.org/[/code] 4.这时候,你再次在终端中运行:

$ sudo gem install cocoapods


5. pod setup  设置pod(翻墙,长时间等待)

注意:.安装cocoapods出现以下错误,需要先升级gem:gem
update --system ——> 重复4步骤

ERROR:  While executing gem ... (Gem::DependencyError)
    Unable to resolve dependencies: cocoapods requires cocoapods-core (= 0.36.3), xcodeproj (~> 0.23.1), cocoapods-downloader (~> 0.9.0), cocoapods-trunk (~> 0.6.0)

--------------------------------   使用(AFNetworking为例) ----------------------------

1. 搜索库版本

$ pod search AFNetworking


2.在工程根目录创建Podfile文件

vim Podfile


内容:

platform :ios, '7.0'
pod "AFNetworking", "~> 2.0"

保存之后运行下载库:

$ pod install

之后会生成pod库文件夹

EricmatoMacBook-Pro:CocoaPodsDemo ericwang$ pod install
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (2.0.2)
Generating Pods project
Integrating client project

[!] From now on use `CocoaPodsDemo.xcworkspace`.

注意最后一句话,意思是:以后打开项目就用 CocoaPodsDemo.xcworkspace 打开,而不是之前的.xcodeproj文件。

tips:pod update 命令升级引用库
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  cocopods安装