Cocoapods简单介绍

Cocoapods是mac下的类库管理工具。

一、安装Cocoapods
1,安装rvm(参考:http://stackoverflow.com/questions/3696564/how-to-update-ruby-to-1-9-x-on-mac)
$curl -L https://get.rvm.io | bash -s stable --ruby
$source /Users/liubo/.rvm/scripts/rvm(不需要执行)
2,重启命令行,更新ruby版本
$rvm list known
$rvm install ruby-2.0.0-p247 && rvm use ruby-2.0.0-p247
$rvm install current && rvm use current
3,安装cocoapods

$ gem sources --remove https://rubygems.org/
//等有反应之后再敲入以下命令
$ gem sources -a http://ruby.taobao.org/
$ gem sources -l
$ sudo gem install cocoapods
二、使用Cocoapods(参考:http://code4app.com/article/cocoapods-install-usage)
1,$pod search AFNetworking //确定github是否有此类库,第一次search时间极长,去喝杯咖啡吧
2,创建Podfile文件,放置在与工程文件.xcodeproj相同的目录即根目录下,内容为添加需要下载的类库:
platform :ios, '7.0'
pod "AFNetworking", "~> 2.0"
3,根目录下执行$pod install文件;
4,根目录出现.xcworkspace、Podfile.lock、Pods目录,使用.xcworkspace打开工程;
5,import <AFNetworking.h> 或者 import "AFNetworking.h"引入头文件。
6,github下载的工程,使用$pod update命令可以更新类库。

posted on 2014-02-21 13:24  离群的野兽  阅读(221)  评论(0编辑  收藏  举报

导航