美文网首页
【iOS开发笔记】Cocoaspods1.9的使用

【iOS开发笔记】Cocoaspods1.9的使用

作者: Mr_Ten | 来源:发表于2020-05-15 13:54 被阅读0次

    1.三言两语阐述下现状

    前因后果暂且不提 ,目前我安装的cocoapods版本是1.9.1,而且是直接安装的新版本,所以.cocoapods/repos/下只有一个trunk,没有master等其他文件夹。
    cocoapods1.8会后CDN被作为spec的默认仓库来源,好处的话第一次安装的时间大幅缩短,不用从https://github.com/CocoaPods/Specs.git上拉取整个仓库代码,后面用到的时候也只会拉取当前所需。
    说起来也是没办法,降级回去安装的时候pod setup下载又卡住,安装不成,只能重新换回1.9继续搞。

    2.主要问题及解决办法

    2.1 RPC failed

    2.1.1 问题描述

    RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54

    2.1.2解决办法

    git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master
    

    或者使用别的源

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

    2.2 trunk连接问题

    2.2.1问题描述

    [!] CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/ Response: 400

    [!] CDN: trunk Repo update failed - 70 error(s): CDN: trunk URL couldn't be downloaded: [库信息], error: Failed to open TCP connection to raw.githubusercontent.com:443

    [!] CDN: trunk Repo update failed - 14 error(s): CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/[库路径].podspec.json Response: Couldn't connect to server

    2.2.2解决办法

    解决思路有两条,一条是退回旧方式,另一条是使用新方式,其中退回旧方式又分为两种。

    2.2.2.1 退回旧方式1 - 回退cocoapods版本

    1.查看gem本地安装的cocoapods版本
    gem list
    2.删除cocoapods和cocoapods-core程序包
    sudo gem uninstall cocoapods -v版本号
    sudo gem uninstall cocoapods-core -v版本号
    3.安装其他版本cocoapods
    sudo gem install cocoapods -v版本号

    2.2.2.2 退回旧方式2 - 指定source源

    1.podfile文件中制定source源为master。
    source 'https://github.com/CocoaPods/Specs.git'
    2.移除trunk源。
    执行pod repo remove trunk

    2.2.2.3 使用新特性,解决DNS污染问题

    1.编辑Podfile,将CDN设置为主要来源,1.8+是默认项

    source 'https://cdn.cocoapods.org/'
    

    2.有master的可以移除master了

    pod repo remove master
    

    3.获得raw.githubusercontent.com的真实ip地址
    可以使用nslookup raw.githubusercontent.com获取
    也可以使用https://www.ipaddress.comhttps://site.ip138.com/raw.githubusercontent.com/输入raw.githubusercontent.com查询ip地址。

    https://site.ip138.com/raw.githubusercontent.com/

    4.修改hosts
    终端输入sudo vi /etc/hosts
    输入i进入编辑模式
    在最后一行添加151.101.76.133 raw.githubusercontent.com
    其中151.101.76.133是上一步中获取的ip地址
    control+c退出编辑
    输入:wq!保存退出

    5.重试下就可以了
    不行的话可以刷新下DNS缓存sudo killall -HUP mDNSResponder

    相关文章

      网友评论

          本文标题:【iOS开发笔记】Cocoaspods1.9的使用

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