pod install CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/......xxx...

1

问题描述

CocoaPods 升级到1.11后,当pod install时,默认会从 CDN 上更新第三方库文件(https://cdn.jsdelivr.net
但是由于地域差异、网路、墙、dns污染等各种原因,会导致pod install 执行失败,此时失败的例子可能如下:

zhangyin@zhangyindeMacBook-Air kdh_iOS % pod install
Analyzing dependencies
[!] The version of CocoaPods used to generate the lockfile (1.11.2) is higher than the version of the current executable (1.11.0). Incompatibility issues may arise.
[!] CDN: trunk Repo update failed - 28 error(s):
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/0.10.0/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/0.11.0/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/0.12.0/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/0.13.0/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/0.14.0/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/0.15.0/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/0.16.0/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/0.17.0/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/0.18.0/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/0.19.0/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/0.19.1/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/0.20.0/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/0.21.0/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/0.21.1/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/0.22.0/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/0.30.0.beta1/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/0.30.0.beta2/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/3.0.0/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/3.0.1/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/3.0.2/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/3.1.2/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/3.2.0/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/4.0.0/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/4.0.1/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/4.2.0/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/5.0.0/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/5.0.1/SnapKit.podspec.json Response: SSL connect error
CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/1/f/6/SnapKit/5.6.0/SnapKit.podspec.json Response: SSL connect error

2

解决思路

CDN无法使用,这个是外部原因,如果有VPN可以试试,但是VPN并不总是有效,毕竟VPN还是架构在你本地的基础网络环境之上。
从CocoaPod 1.8.0开始,系统默认通过CDN 的方式来pod install,目前最新的版本是1.11.3。

先看下故障现场的情况:
通过pod repo list 可以看到当前的pod 索引库:

zhangyin@zhangyindeMacBook-Air kdh_iOS % pod repo
trunk
- Type: CDN
- URL:  https://cdn.cocoapods.org/
- Path: /Users/zhangyin/.cocoapods/repos/trunk

此时,新安装好的CocoaPods 1.11.0 版本的Pod索引库的Type是CDN方式的,执行pod install 就会默认走trunk这个索引库。
但是因为网络问题,此路不通,那么就换一条路:更换Pod索引库。

3

解决方案:强制Pod install时采用自定义的Pod索引库

第1步:添加新的Pod索引库的源:

姿势1:添加 官方 CocoaPods Git 源
执行 pod repo add cocoapods https://github.com/CocoaPods/Specs.git
说明:
既然CDN都无法使用,官方的pod repo的源大概率也不太好使,可以多试几次,实在不行就不要用官方的源了;

下面这个例子就是添加官方源失败的现场:
现场报出各种稀奇古怪的错误,此时不要恋战,赶紧换姿势;

zhangyin@zhangyindeMacBook-Air kdh_iOS % pod repo add cocoapods https://github.com/CocoaPods/Specs.git
Cloning spec repo `cocoapods` from `https://github.com/CocoaPods/Specs.git`
[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git -- cocoapods

Cloning into 'cocoapods'...
error: RPC failed; curl 92 HTTP/2 stream 5 was not closed cleanly before end of the underlying stream
error: 6614 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output

姿势2:添加自定义Pod 索引库的源
添加大名鼎鼎的 清华 CocoaPods 镜像源
执行 pod repo add tuna https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git

zhangyin@zhangyindeMacBook-Air local % pod repo add tuna https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git
Cloning spec repo `tuna` from `https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git`

速度还不错,添加好后执行pod repo list看看效果:

zhangyin@zhangyindeMacBook-Air local % pod repo list

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

tuna
- Type: git (remotes/origin/master)
- URL:  https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git
- Path: /Users/zhangyin/.cocoapods/repos/tuna

2 repos

多了一个:名叫‘tuna’的Pod 源,Type为git方式;

第2步:更新本地的Pod 索引库的缓存信息

执行 pod repo update --verbose

zhangyin@zhangyindeMacBook-Air kdh_iOS % pod repo update --verbose
  CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only performed in repo update

Updating spec repo `trunk`
  CDN: trunk Relative path downloaded: deprecated_podspecs.txt, save ETag: W/"6287c3f3-940fe"
  CDN: trunk Going to update 3 files
  CDN: trunk Relative path: CocoaPods-version.yml, has ETag? "6287b0a4-38"
  CDN: trunk Relative path: all_pods_versions_1_f_6.txt, has ETag? W/"6287bdf6-472"
  CDN: trunk Relative path: all_pods_versions_f_4_e.txt, has ETag? W/"6287b0a4-50b"
  CDN: trunk Relative path downloaded: CocoaPods-version.yml, save ETag: "6287c8ad-38"
  CDN: trunk Relative path downloaded: all_pods_versions_1_f_6.txt, save ETag: W/"6287c8ad-472"
  CDN: trunk Relative path downloaded: all_pods_versions_f_4_e.txt, save ETag: W/"6287c8ad-50b"

CocoaPods 1.11.3 is available.
To update use: `sudo gem install cocoapods`

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.11.3


Updating spec repo `tuna`
  $ /usr/bin/git -C /Users/zhangyin/.cocoapods/repos/tuna fetch origin --progress
  $ /usr/bin/git -C /Users/zhangyin/.cocoapods/repos/tuna rev-parse --abbrev-ref HEAD
  master
  $ /usr/bin/git -C /Users/zhangyin/.cocoapods/repos/tuna reset --hard origin/master
  HEAD is now at ef488a02bffb [Add] QiscusMultichannelWidget 2.0.4-beta.2

至此,添加新的Pod索引库完成

第3步:

在自己项目的Podfile文件的第一行中,添加声明,告诉系统pod install时需使用自定义的Pod索引库,例如:(本例中使用的是清华的源)

source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'

target 'MyProject' do
  use_frameworks!
end

如果一切顺利,此时就可以愉快的执行 pod install 操作了,例如:

zhangyin@zhangyindeMacBook-Air kdh_iOS % pod install
Analyzing dependencies
Downloading dependencies
Generating Pods project
Integrating client project
Pod installation complete! There are 31 dependencies from the Podfile and 35 total pods installed.

[!] Unable to read the license file `FILE_LICENSE` for the spec `YXAlog_iOS (1.0.6)`

[!] Unable to read the license file `FILE_LICENSE` for the spec `YXAlog_iOS (1.0.6)`

[!] Unable to read the license file `FILE_LICENSE` for the spec `YXAlog_iOS (1.0.6)`

[!] Unable to read the license file `FILE_LICENSE` for the spec `YXAlog_iOS (1.0.6)`

[!] The `kdh [Debug]` target overrides the `EXCLUDED_ARCHS[sdk=iphonesimulator*]` build setting defined in `Pods/Target Support Files/Pods-kdh/Pods-kdh.debug.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `kdhUITests [Debug]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-kdh-kdhUITests/Pods-kdh-kdhUITests.debug.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `kdhUITests [Release]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-kdh-kdhUITests/Pods-kdh-kdhUITests.release.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `kdhUITests [AdHoc]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-kdh-kdhUITests/Pods-kdh-kdhUITests.adhoc.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] Your project does not explicitly specify the CocoaPods master specs repo. Since CDN is now used as the default, you may safely remove it from your repos directory via `pod repo remove master`. To suppress this warning please add `warn_for_unused_master_specs_repo => false` to your Podfile.

4

番外篇

flutter项目中 .ios 目录下的Podfile文件中的第一行也需要添加使用自定义Pod索引库的的声明语句,这样在vscode中使用iOS模拟器运行flutter项目时,pod install才可以正确运行,例如:

source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoadPods/Specs.git'

target 'MyProject' do
  use_frameworks!
end
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,271评论 5 476
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,275评论 2 380
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,151评论 0 336
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,550评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,553评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,559评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,924评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,580评论 0 257
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,826评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,578评论 2 320
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,661评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,363评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,940评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,926评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,156评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,872评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,391评论 2 342

推荐阅读更多精彩内容