CocoaPods 是 iOS 最常用最有名的类库管理工具

安装

  1. # 添加源
  2. $ sudo gem sources -a https://gems.ruby-china.org/
  3. # 删除源
  4. $ sudo gem sources -r https://rubygems.org/
  5. # 安装
  6. $ sudo gem install cocoapods
  7. # 设置
  8. $ pod setup

使用

  1. # 搜索
  2. $ pod search AFNetworking
  3. # 生成 Podfile
  4. $ echo "pod 'AFNetworking'" > Podfile
  5. # 安装
  6. $ pod install
  7. # 升级
  8. $ pod update
  9. # 查看版本
  10. $ pod --version

注意:

  1. # 执行pod install还是pod update卡在了Analyzing dependencies不动
  2. # 忽略升级CocoaPods的spec仓库
  3. pod install --verbose --no-repo-update
  4. pod update --verbose --no-repo-update

git 操作

  1. # 将修改添加到暂存区
  2. $ git add .
  3. # 提交修改
  4. $ git commit -m "添加 AFN框架程序"

gem 常用命令

  1. # 查看gem源
  2. $ gem sources l
  3. # gem自身升级
  4. $ sudo gem update --system
  5. # 查看版本
  6. $ gem --version
  7. # 清除过期的gem
  8. $ sudo gem cleanup
  9. # 安装包
  10. $ sudo gem install cocoapods
  11. # 删除包
  12. $ gem uninstall cocoapods
  13. # 更新包
  14. $ sudo gem update
  15. # 列出本地安装的包
  16. $ gem list
  17. # 升级cocoapods
  18. $ sudo gem install -n /usr/local/bin cocoapods --pre

换源为cocoapods pod upate 提速

新版的 CocoaPods 不允许用pod repo add直接添加master库了,但是依然可以:

  1. $ cd ~/.cocoapods/repos
  2. $ pod repo remove master
  3. $ git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master

最后进入自己的工程,在自己工程的podfile第一行加上:

  1. source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'

清华大学换源官方文档: https://mirror.tuna.tsinghua.edu.cn/help/CocoaPods/

插件

  1. curl -fsSL https://raw.github.com/supermarin/Alcatraz/master/Scripts/install.sh | sh

github 地址:https://github.com/supermarin/Alcatraz