美文网首页Xcode项目构建
CocoaPods在pod setup失败

CocoaPods在pod setup失败

作者: SkyMing一C | 来源:发表于2019-06-30 22:02 被阅读2次

CocoaPods在pod setup失败"RPC failed; curl 18 transfer closed with outstanding read data remaining"

报错内容

  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

解决方法:

1. 进入repos目录下
cd ~/.cocoapods/repos

如果没有该目录:

sudo gem install cocoapods

出现.cocoapods的目录后可以ctrl+c终止安装。
备注:苹果系统升级 OS X EL Capitan 后改为

sudo gem install -n /usr/local/bin cocoapods
2. 更换镜像下载地址
  • 旧版的 CocoaPods 可以使用如下方法使用国内的的镜像(以清华的镜像为例):
pod repo remove master
pod repo add master https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git
pod repo update
  • 新版的 CocoaPods 不允许用pod repo add直接添加master库了,但是依然可以 git clone
pod repo remove master
git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master

成功时显示

Cloning into 'master'...
remote: Counting objects: 3260580, done.
remote: Compressing objects: 100% (1012292/1012292), done.
remote: Total 3260580 (delta 2058490), reused 3250757 (delta 2050967)
Receiving objects: 100% (3260580/3260580), 584.59 MiB | 2.65 MiB/s, done.
Resolving deltas: 100% (2058490/2058490), done.
Checking out files: 100% (339686/339686), done.
3. 将origin地址更换为官方原地址
  • 前往文件夹repos(前往快捷键Command + Shift + G)
~/.cocoapods/repos/
成功时文件分布
  • 显示隐藏的文件

    • “隐藏文件”命令
    defaults write com.apple.finder AppleShowAllFiles -bool true
    defaults write com.apple.finder AppleShowAllFiles -bool false
    
    • 快捷键
    Command + Shift + .
    
  • 打开master下隐藏文件夹.git下config配置文件

~/.cocoapods/repos/master/.git/config
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
  • 修改origin中的url为官方CocoaPods/Specs的url
...
[remote "origin"]
    url = https://github.com/CocoaPods/Specs.git
    fetch = +refs/heads/*:refs/remotes/origin/*
...
3. 执行搜索测试是否成功
pod search afnetworking

成功之后

搜索测试

资料

  • 清华大学镜像
https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git

  • 上海大学镜像
https://mirrors.shu.edu.cn/CocoaPods (仅HTTP/HTTPS访问,不支持git拉取) 
https://mirrors.shu.edu.cn/mgit/Specs (仅git访问) 
https://git.shuosc.org/CocoaPods/Specs (均支持)

  • COCOAPODS SPECS 中国区镜像
git://cocoapodscn.com/Specs.git

参考

cocoapods国内镜像

相关文章

网友评论

    本文标题:CocoaPods在pod setup失败

    本文链接:https://www.haomeiwen.com/subject/ijipcctx.html