cocoapods 换源

1. 用以下步骤换源:

pod repo remove master
pod repo add master https://code.aliyun.com/Magi/CocoaPods.git
pod repo update

执行repo add时报错:[!] To setup the master specs repo, please run pod setup

2. 用以下方法也特别慢,aliyun好像只支持ssh,gitclub也只有10-20k,git clone一半断掉又不能断点续传

git clone https://gitclub.cn/CocoaPods/Specs.git ~/.cocoapods/repos/master
pod repo update

测下来,阿里云的源最快(ping值都在10ms左右,clone速度>300k),阿里云加公钥后可用ssh clone,下了5个G都只有52%,感觉踩坑了,一般只有几百兆到1个G
https://code.aliyun.com/Magi/CocoaPods.git
https://gitclub.cn/CocoaPods/Specs.git
https://git.coding.net/hging/Specs.git

3. 最终的方法:

  • 从同事那儿AirDrop把~/.cocoapods/repos/master这个目录拷贝过来,到相同位置
  • 手工修改master/.git/config里的url = https://code.aliyun.com/Magi/CocoaPods.git
  • pod repo 显示源已经改过来了
  • 项目的Podfile里一定要指定source 'https://code.aliyun.com/Magi/CocoaPods.git',否则还是会从github更新,并且还会把设置好的源改回去!这点特别坑,我试了无数次。
source 'https://code.aliyun.com/Magi/CocoaPods.git'
platform :ios,'9.0'
target 'TestIosObjectC' do
pod 'SDAutoLayout'
end

参考:《swift cocoapods配置》:这篇说的比较好,把我遇到的问题都覆盖了

原文地址:https://www.cnblogs.com/AlexanderYao/p/8011508.html