执行克隆 clone 命令后出现了如下异常:
fyhsurvivors@survivors-deMacBook-Pro repos % git clone https://github.com/CocoaPods/Specs.git master
Cloning into 'master'...
remote: Enumerating objects: 402, done.
remote: Counting objects: 100% (402/402), done.
remote: Compressing objects: 100% (383/383), done.
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
error: rev-list died of signal 9
fatal: remote did not send all necessary objects
解决办法
如下操作的 CocoaPods 版本为 1.9.1
首先,终端执行如下命令,查看当前是否配置 repo 源
CocoaPods 即 Cocoa、Cocoa Touch 框架依赖管理器,类似于 Homebrew 都是通过索引的方式从 GitHub 下载依赖的 code;
pod repo
若非 0 repos 存在可尝试移除重新添加源信息,反之跳过 remove 操作继续下一步,配置新 repo 源;
pod repo remove master
其次,添加新的 repo 源,将其配置为 清华大学开源镜像地址
source 'https://github.com/CocoaPods/Specs.git' 国内访问较慢且不稳定,可尝试如下 source 源
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
// 新版本 CocoaPods
cd ~/.cocoapods/repos
pod repo remove master
git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master
Cloning into 'master'...
remote: Counting objects: 3979483, done.
remote: Compressing objects: 100% (1188253/1188253), done.
remote: Total 3979483 (delta 2574936), reused 3969414 (delta 2567216)
Receiving objects: 100% (3979483/3979483), 645.70 MiB | 6.34 MiB/s, done.
Resolving deltas: 100% (2574936/2574936), done.
Updating files: 100% (408365/408365), done.
注:若为旧版本 CocoaPods 使用如下方式,因新版本不允许使用 pod repo add 直接进行添加操作
// 旧版本 CocoaPods
pod repo remove master
pod repo add master https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git
pod repo update
再其次,repo 配置成功,切换至对应的项目并将其 Podfile 文件中添加如下 source 配置
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
最后,终端 cd 项目工程文件目录下,执行 pod install 即可。
若执行 install 仍失败可尝试执行如下命令后再次尝试 install
sudo xcode-select --switch /Applications/Xcode.app
以上便是此次分享的全部内容,希望能对大家有所帮助!
网友评论