美文网首页666IOSiOS开发与OC、Swift进阶
pod install 速度慢解决办法

pod install 速度慢解决办法

作者: 冲云简 | 来源:发表于2020-11-18 17:28 被阅读0次

首先我们查看gem使用源, 如果是淘宝源,请替换为:https://gems.ruby-china.com/

$gem sources --remove https://rubygems.org/
$gem sources -a https://gems.ruby-china.com
$gem sources -l
https://gems.ruby-china.com/

更新cocoapods

// 如果之前有
$sudo gem uninstall cocoapods (移除原来的cocoapods)
// 安装CocoaPods(OS X 10.11以前)
$sudo gem install cocoapods
// 安装CocoaPods(10.11后苹果升级了安全策略)
$sudo gem install -n /usr/local/bin cocoapods

cocoapod使用国内镜像

$pod repo remove master
$pod repo add master https://gitee.com/mirrors/CocoaPods-Specs.git
$pod repo
master
- Type: git (unknown)
- URL:  https://gitee.com/mirrors/CocoaPods-Specs.git
- Path: /Users/channel-joyce/.cocoapods/repos/master

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

pod install 尽量使用:

$pod install --no-repo-update

使用proxychains使终端命令走代理

最后,如果还是慢,真正的解决方案就是要加快git命令的速度。

我使用Shadowsocks代理,默认代理端口为1080,配置好代理之后去终端输入git配置命令,命令如下

$git config --globalhttp.proxy socks5://127.0.0.1:1080

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

$git config --global http.https://github.com.proxy socks5://127.0.0.1:1080

如此就从根本上解决了问题

体验xiu的一下吧!

ps:如果要恢复/移除上面设置的git代理,使用如下命令

$git config --global --unset http.proxy
//[github.com.proxy](http://github.com.proxy/)
$git config --global --unset http.https:

如果你是第一次装cocoapods,请参考最后一个链接

$ping github.com

如果ping 不上github.com,请尝试更改host,

sudo vi /etc/hosts

编辑hosts,将github.com 的ip地址增加到host中。


截屏2022-02-11 上午10.35.16.png

参考链接:
https://blog.csdn.net/devday/article/details/105134394
https://www.cnblogs.com/dabaomo/p/9634727.html
https://blog.csdn.net/this_ITBoy/article/details/121835075

相关文章

网友评论

    本文标题:pod install 速度慢解决办法

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