CocoaPods-pod update 慢的解決辦法(非常實(shí)用)

由于開發(fā)的過程中,經(jīng)常遇到pod update比較慢的情況,所以記錄下實(shí)用的方法,備忘下。這個(gè)是在CSND上看到的,但原文章沒有提供端口的獲取方式。

此方法主要通過修改git的代理配置,主要是端口號(hào),從而解決git連接github遠(yuǎn)程比較慢的問題。

1.獲取代理工具的端口號(hào)。
例如shandowsocks的:


4539EF2B-49C2-4ED8-8EBF-246E1C3FF889.png

2.依次輸入兩個(gè)命令:

/* !!!!//127.0.0.1:1086 和//127.0.0.1:1086。并不是注釋,而是命令的一部分 */
git config --global http.proxy socks5://127.0.0.1:1086
git config --global http.https://github.com.proxy socks5://127.0.0.1:1086

執(zhí)行后可重新pod update 嘗試。如果沒有改善,那么可以回滾,使用其他優(yōu)化方式(如果是shandowsocks,有可能需要開啟手動(dòng)模式的代理)。
回滾操作:

git config --global --unset http.proxy
git config --global --unset http.https://github.com.proxy

python更新腳本

import os
import sys
import subprocess

#param  -on -off
class GitConfig:

    def __init__(self):
        pass

    def setGitConfig():
        cmd = 'git config --global http.proxy socks5://127.0.0.1:1086'
        cmd1 = 'git config --global http.https://github.com.proxy socks5://127.0.0.1:1086'
        subprocess.call(cmd,shell = True)
        subprocess.call(cmd1,shell = True)
        print('set github confif proxy')
        subprocess.call('git config --global  --list',shell = True)
        pass

    def resetGitConfig():
        cmd = 'git config --global --unset http.proxy'
        cmd1 = 'git config --global --unset http.https://github.com.proxy'
        subprocess.call(cmd,shell = True)
        subprocess.call(cmd1,shell = True)
        print('reset github confif proxy')
        subprocess.call('git config --global  --list',shell = True)
        pass


if __name__ == "__main__" :
    params = sys.argv

    if len(params) > 1 :
        sw = params[1]
        if sw.lower() == '-on' or sw.lower() == '-off' :
            gitConfig = GitConfig
            if sw.lower() == '-on' :
                gitConfig.setGitConfig()
            else:
                gitConfig.resetGitConfig()

link:
pod install速度慢的終極解決方案

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容