CocoaPods错误:CDN: trunk URL couldn't be downloaded:......(Connection refused

本文解决在使用CocoaPods时遇到的podsearch错误问题,详细介绍了如何通过更改podfile源和移除trunk源来修复连接失败和超时错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

执行pod search时候出错:

$pod search YYWebImage

报错信息:

CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/4/c/8/YYWebImage/1.0.3/YYWebImage.podspec.json, error: Failed to open TCP connection to raw.githubusercontent.com:443 (Connection refused - connect(2) for "raw.githubusercontent.com" port 443)

实验发现,pod install和pod update也是这个样子,各种找,原因和解决方法 如下:

CocoaPods 1.8将CDN切换为默认的spec repo源,并附带一些增强功能!CDN支持最初是在1.7版本中引入的,最终在1.7.2中完成。 它旨在大大加快初始设置和依赖性分析。

目前电脑上安装的pods是1.8.4版本

$ pod --version

1.8.4

按照官方文档的指导,在项目podfile文件中添加source源:
source 'https://github.com/CocoaPods/Specs.git'
podfile文件中添加source源后,pod installpod update可以正常操作,但是pod search有些库却仍旧不正常。

$ pod search mj
[!] CDN: trunk Repo update failed - 3 error(s):
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/0/f/b/MJRefresh/0.0.1/MJRefresh.podspec.json, error: Operation timed out - SSL_connect
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/0/f/b/MJRefresh/1.4.4/MJRefresh.podspec.json, error: Operation timed out - SSL_connect
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/0/f/b/MJRefresh/2.4.9/MJRefresh.podspec.json, error: Operation timed out - SSL_connect

$ pod search rbtitle
-> RBTitleView (2.0.1)
   简单实用的titleView
   pod 'RBTitleView', '~> 2.0.1'
   - Homepage: https://github.com/RiberWang/RBTitleDemo
   - Source:   https://github.com/RiberWang/RBTitleDemo.git
   - Versions: 2.0.1, 1.0.1, 1.0.0 [master repo]

解决办法:

1. podfile文件中指定source源为master:

source 'https://github.com/CocoaPods/Specs.git'

2.执行pod repo remove trunk移除trunk源

执行完后,pod search就都正常了!

$ pod repo list

master
- Type: git (master)
- URL:  https://github.com/CocoaPods/Specs.git
- Path: /Users/Riber/.cocoapods/repos/master

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

2 repos
Ribers-Mac:ZNB_Country2.0 Riber$ pod repo remove trunk
Removing spec repo `trunk`

注意:podfile文件中一定要指定master源,因为现在默认是trunk

source 'https://github.com/CocoaPods/Specs.git'

参考文章:

  1. 官方说明
  2. Github Issules
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

auspark

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值