安装
基础软件
命令: sudo gem install -n/usr/local/bin cocoapods
国内换源
CocoaPods 是一个 Cocoa 和 Cocoa Touch 框架的依赖管理器,具体原理和 Homebrew 有点类似,都是从 GitHub 下载索引,然后根据索引下载依赖的源代码。
国内Homebrew源汇总
官方源
$ cd ~/.cocoapods/repos
$ pod repo remove master
$ git clone https://github.com/CocoaPods/Specs master
清华源
$ cd ~/.cocoapods/repos
$ pod repo remove master
$ git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master
gitee源
$ cd ~/.cocoapods/repos
$ pod repo remove master
$ git clone https://gitee.com/mirrors/CocoaPods-Specs.git master
阿里云源
$ cd ~/.cocoapods/repos
$ pod repo remove master
$ git clone https://github.com/aliyun/aliyun-specs.git master
在Podfile第一行加上使用的源:
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
CDN如果顺畅了,也可以换CDN的方式,但经常遇到网络问题,不过成功率比直接访问github的高多了。
pod 命令执行出错
错误提示
curl: (60) SSL certificate problem: unable to get local issuer certificate
解决方案
echo insecure >> ~/.curlrc
pod写法记录
pod 'Name', '0.1.8'
pod 'Name', :git => 'http://github.com/iOS/Name.git', :commit => 'commit_id'
pod 'Name', :git => 'http://github.com/iOS/Name.git', :commit => 'commit_id', :configurations => ['Debug', "Beta"]
pod 'Name', :git =>'http://github.com/iOS/Name.git', :tag =>'tag'
pod 'Name', :git =>'http://github.com/iOS/Name.git', :tag =>'tag', :configurations => ['Release']
pod 'Name', :git => 'http://github.com/iOS/Name.git', :branch => 'branch'
pod 'Name', :path => '../../Name'
pod 'Name', :podspec => 'https://github.com/Name.podspex'
pod 'Name', :git => "https://github.com/Name", :tag => "1.0.0", :submodules => true
pod 'Name', 'tag', :source => 'https://github.com/XXX/XXX.git'
语法案例参考 Podfile