pod install速度慢 解决方案

最近使用CocoaPods来添加第三方类库,无论是执行pod install还是pod update都卡在了Analyzing dependencies不动

原因在于当执行以上两个命令的时候会升级CocoaPods的spec仓库,加一个参数可以省略这一步,然后速度就会提升不少。加参数的命令如下:

pod install --verbose --no-repo-update

pod update --verbose --no-repo-update




$ gem sources --remove https://rubygems.org/

$ gem sources -a http://ruby.taobao.org/

使用淘宝的镜像会快不少。

这个是安装 cocopods 用的吧,但是安装好之后的  pod install  和它就没有关系了。




相信大家已经感受到pod install速度越来越慢了,网上提供了几种解决方案,但是都没有完全解决速度慢的问题。

  1. 使用国内镜像的Specs
  2. 在pod install时使用命令pod install --no-repo-update
  3. 使用proxychains使终端命令走代理

下面就来说明一下这几种方法为何没有完全解决问题

  1. 使用国内镜像的Specs 
    这个只是加快了Specs下载更新速度,而且如果使用国内镜像Specs,那么Podfile中就必须指明使用这个Specs。
  2. 在pod install时使用命令pod install --no-repo-update 
    install时不更新本地库,但如果第一次install还是要去github clone代码
  3. 使用proxychains使终端命令走代理 
    这个只是使pod命令走代理,git download的时候不会走代理

其实真正慢的原因并不在pod命令,而是在于github上的代码库访问速度慢,那么就知道真正的解决方案就是要加快git命令的速度。 
我使用Shadowsocks代理,默认代理端口为1080,配置好代理之后去终端输入git配置命令,命令如下

<code class="hljs fsharp has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">git config --<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">global</span> http.proxy socks5:<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//127.0.0.1:1080</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

上面的命令是给git设置全局代理,但是我们并不希望国内git库也走代理,而是只需要github上的代码库走代理,命令如下

<code class="hljs avrasm has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">git config --global http<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.https</span>://github<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.com</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.proxy</span> socks5://<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">127.0</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.0</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.1</span>:<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1080</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

如此就从根本上解决了问题,下面附上设置代理前后git命令的速度 
代理前 
代理前
代理后 
这里写图片描述

体验xiu的一下吧!


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值