折腾一个下午和晚上,分享以帮助正在探索的小伙伴们:
参照清华的一个镜像:https://mirror.tuna.tsinghua.edu.cn/help/CocoaPods/
CocoaPods 是一个 Cocoa 和 Cocoa Touch 框架的依赖管理器,具体原理和 Homebrew 有点类似,都是从 GitHub 下载索引,然后根据索引下载依赖的源代码。
但是GitHub上拷贝下来太难了;
1、于是,就有想到清华大学的这个cocospods镜像。
进入正题:
对于旧版的 CocoaPods 可以使用如下方法使用 tuna 的镜像:
$ pod repo remove master
$ pod repo add master https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git
$ pod repo update
新版的 CocoaPods 不允许用pod repo add
直接添加master库了,但是依然可以:(我新版的cocospods,实测可行)
$ cd ~/.cocoapods/repos
$ pod repo remove master
$ git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master
最后进入自己的工程,在自己工程的podFile
第一行加上:
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
添加库到工程