iOS-cocoapods使用方法

1.CocoaPods的安装及使用:
查看当前的源
gem sources -l
gem sources --remove  https://rubygems.org/
//等有反应以后再敲入如下命令,添加淘宝镜像
gem sources -a  https://ruby.taobao.org/
只有在终端中出现下面文字才代表你上面的命令是成功的:
*** CURRENT SOURCES ***
这时候,你再次在终端中运行:
--verbose参数表示显示指令的执行过程
sudo gem install cocoapods --verbose
//将 CocoaPods Specs repository复制到你电脑上~/.cocoapods目录下,
它须要一点时间来完成,你等就是了
pod setup
若是安装失败 ~/.cocoapods 里面是空的,就须要从新setup
命令以下:
pod repo remove master  
pod setup
执行pod setup若是出现以下报错
[!] /usr/bin/git clone  https://github.com/CocoaPods/Specs.git master --depth=1
xcrun: error: active developer path ("/Volumes/Xcode/Xcode.app/Contents/Developer") does not exist, use `xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools (or see `man xcode-select`)
则执行:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
若是Ruby环境不够新,可能须要更新如下:
sudo gem update --system
查看版本:
pod --version
搜索:
pod search AFNetworking
生成Podfile文件
pod init
Podfile文件示例:
platform :ios, '6.0'
target 'iOSDevTemplate' do
pod 'AFNetworking'      //不显式指定依赖库版本,表示每次都获取最新版本
pod 'AFNetworking',  ‘2.0’     //只使用2.0版本
pod 'AFNetworking', ‘>2.0′     //使用高于2.0的版本
pod 'AFNetworking', ‘>=2.0′     //使用大于或等于2.0的版本
pod 'AFNetworking', ‘<2.0′     //使用小于2.0的版本
pod 'AFNetworking', ‘<=2.0′     //使用小于或等于2.0的版本
pod 'AFNetworking', ‘~>0.1.2′   //使用大于等于0.1.2但小于0.2的版本,至关于>=0.1.2而且<0.2.0
pod ‘AFNetworking’, ‘~>0.1′     //使用大于等于0.1但小于1.0的版本
pod ‘AFNetworking’, ‘~>0′     //高于0的版本,写这个限制和什么都不写是一个效果,都表示使用最新版本
end
下载开源库:
pod install --no-repo-update --verbose
更新开源库:
pod update --no-repo-update --verbose
更新本地索引库
pod repo update --verbose
相关文章
相关标签/搜索