原地址:http://www.cnblogs.com/Crazy-D/p/6421611.html
1、查看ruby源
gem sources -l
2、移除掉原有的源
gem sources --remove https://rubygems.org/
3、添加国内最新的源。ruby-china
gem sources -a https://gems.ruby-china.org
4、检查是否添加成功
gem sources -l
5、安装cocoapods
sudo gem install -n /usr/local/bin cocoapods
6、安装完成后查看pod版本
pod --version
7、更新Podspec索引文件,创建本地索引库(这里要多等一会儿)
pod setup
8、进入项目目录
cd ~
9、创建Podfile文件
vim Podfile
10.单击“I”进入编辑状态
11、编辑Podfile文件
platform:ios,'7.0'
target 'ProductCode' do //"ProductCode"是项目名
pod 'ZXing', '~> 2.3'
end
12.单击“esc”退出编辑,写入":wq"退出编辑
//注cocoapods Podfile文件编写需有target + 项目名 + do
pod 'ZXing', '~> 2.3'
pod 'pop','~>1.0'
pod 'MBProgressHUD+JDragon','~> 1.0.0’
pod 'SDAutoLayout','~> 2.1.7’
pod 'AFNetworking', '~> 3.0'
pod 'MJRefresh', '~> 1.4.6'
13、安装依赖库
pod install(后续添加框架可直接pod update)