查看本地源
pod repo
默认master镜像
master
- Type: git (master)
- URL: https://github.com/CocoaPods/Specs
- Path: /Users/xxx/.cocoapods/repos/master
修改默认镜像
国内网络限制,github源下载麻烦,可以切换默认master源
清华源:https://mirrors.tuna.tsinghua.edu.cn/help/CocoaPods/
gitee源:https://gitee.com/mirrors/CocoaPods-Specs.git
以清华源为例
对于旧版的 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库了,但是依然可以:
$ 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'
恢复默认gihub源
cd ~/.cocoapods/repos
pod repo remove master
git clone https://github.com/CocoaPods/Specs master
最后别忘了修改podfile文件:
source 'https://github.com/CocoaPods/Specs'
重要来了,如果还是想用gihub源,git clone又不能成功怎么办
可以在github上直接下载,Chrome具有断网续连功能,可以下载zip
https://github.com/CocoaPods/Specs
然后把压缩包解压在
/Users/xxx/.cocoapods/repos/
取名master,然后新建一个隐藏文件夹.git或者从其他源中复制一份.git文件夹,然后修改里面的config文件
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = https://github.com/CocoaPods/Specs
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
然后在执行pod repo,查看当前源,就可以使用自己下载的github源了。