iOS解决cocoapods 搜索速度慢或者搜索失败问题

场景:
最近新购一台macbook,安装cocoapods时,执行pod search 一直无响应,过段时间后,提示[!] CDN: trunk Repo update failed或者[!] CDN: trunk URL couldn't be downloaded: 相关提示。
解决问题步骤:
一.在此安装cocoapods的步骤就不多介绍了,可以在网上搜索或者看下我的简历文章关于cocoapods安装介绍,提出需要注意的几点:
1.https://ruby.taobao.org/已经不能使用
2.gem sources --add https://gems.ruby-china.org/
需要改为gem sources --add https://gems.ruby-china.com/
3.新版Mac执行pod setup 无提示,pod init/pod install/pod update/pod --version都正常使用,唯独pod search不能使用
二.解决步骤
2.1进入cocoapods目录下

cd ~/.cocoapods/repo

2.2查看list

pod repo list
//发现只有trunk 没有master
trunk
- Type: CDN
- URL:  https://cdn.cocoapods.org/
- Path: /Users/liguoqing/.cocoapods/repos/trunk

2.3方法1
按照官方文档 podfile文件中添加source源:
source 'https://github.com/CocoaPods/Specs.git'
只能在项目中pod search 在全局目录下pod search还是无法正常使用,而且速度还是很慢。
2.4方法2
在cocoapods/repo目录下执行.克隆CocoaPods/Specs

git clone https://git.coding.net/CocoaPods/Specs.git

完成后执行open命令,打开repos目录

open .

2.5将Specs目录改成master,成功之后如下图:


image.png

2.6查看list

liguoqingdeMBP:.cocoapods liguoqing$ pod repo list

master
- Type: git (master)
- URL:  https://git.coding.net/CocoaPods/Specs.git
- Path: /Users/liguoqing/.cocoapods/repos/master

trunk
- Type: CDN
- URL:  https://cdn.cocoapods.org/
- Path: /Users/liguoqing/.cocoapods/repos/trunk

2 repos

2.7执行pod repo remove trunk移除trunk源,pod search就都正常了!

liguoqingdeMBP:.cocoapods liguoqing$ pod repo remove 'trunk'
Removing spec repo `trunk`

参考链接:
https://www.jianshu.com/p/bf1cbe49cb5d
https://www.jianshu.com/p/d326fc80c719

你可能感兴趣的:(iOS解决cocoapods 搜索速度慢或者搜索失败问题)