一. 起因
自从GitHub
开始和微软合作之后,就发现各种被墙。
- 最近
CocoaPods
用着还好么? - 最近
Homebrew
用着还好么?
我们亲测一下,就是下面的结果,完全ping
不上。
PING github.com (13.229.188.59): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
Request timeout for icmp_seq 5
Request timeout for icmp_seq 6
Request timeout for icmp_seq 7
Request timeout for icmp_seq 8
Request timeout for icmp_seq 9
Request timeout for icmp_seq 10
二. 导致哪些问题
CocoaPods无法使用
我尝试查询我的project_ios
项目哪些依赖库需要升级,使用pod outdated
命令进行查询。
结果,等待了好久,显示了如下错误。
➜ project_ios git:(develop) pod outdated
Updating spec repo `master`
$ /usr/bin/git -C /Users/shc_retina/.cocoapods/repos/master fetch origin
--progress
fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60
[!] CocoaPods was not able to update the `master` repo. If this is an unexpected issue and persists you can inspect it running `pod repo update --verbose`
分析错误:unable to access 'https://github.com/CocoaPods/Specs.git/',就是访问不上CocoaPods仓库。
或许有人会问,我明明已经更换了gem源,为什么还是会这样呢?
其实你更换gem
源只能影响你安装CocoaPods
的速度。
通俗的讲就是CocoaPods
工具是存放在gem
源中,而你需要的SDWebImage
,AFNetworking
等项目框架是存放在CocoaPods
仓库中的。
问题根源:CocoaPods
仓库无法访问。
以此类推,如果有可以更换CocoaPods
镜像,那么问题也解决了。
但我不想这么解决,因为还有其他问题。
Homebrew无法使用
省略:其实原因和CocoaPods
一样,就是GitHub无法访问了。
三. 解决办法
ShadowsocksX
+ Git
代理设置
既然是GitHub被墙了,我们就翻墙。
那么有人会说,我明明已经用ShadowsocksX-NG
翻墙了,不管是设置全局模式还是PAC自动模式,为啥还是不行呢?
当然不能,终端是没有翻墙的。
但是我们给出的方案却不是让终端翻墙。
那么为什么让终端翻墙呢,只是因为这样不是很安全。
方法如下:
1. 查看你的翻墙工具的Socks5
监听地址和端口号

2. 设置git全局代理
// 设置你自己的IP和host
git config --global http.proxy 'socks5://127.0.0.1:1086'
git config --global https.proxy 'socks5://127.0.0.1:1086'
使用git config --global --list
命令查看是否配置成功
➜ ~ git config --global --list
core.excludesfile=/Users/xxxxxx/.gitignore_global
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE"
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED"
mergetool.sourcetree.trustexitcode=true
http.proxy=socks5://127.0.0.1:1086
https.proxy=socks5://127.0.0.1:1086
user.name=xxxxxxxx
user.email=xxxxxxxx@qq.com
如果需要移除git代理配置,可以用下面命令
git config --global --unset http.proxy
git config --global --unset https.proxy
3. ShadowsocksX开启全局模式

成功了,接下来就可以开心的使用了。
实例如下
➜ shc_ios git:(develop) pod outdated
Updating spec repo `master`
$ /usr/bin/git -C /Users/shc_retina/.cocoapods/repos/master fetch origin
--progress
remote: Counting objects: 1379, done.
remote: Compressing objects: 100% (170/170), done.
remote: Total 1379 (delta 642), reused 596 (delta 593), pack-reused 604
Receiving objects: 100% (1379/1379), 224.27 KiB | 8.63 MiB/s, done.
Resolving deltas: 100% (841/841), completed with 299 local objects.
From https://github.com/CocoaPods/Specs
ac4c4ace97b..e1d350b456a master -> origin/master
$ /usr/bin/git -C /Users/shc_retina/.cocoapods/repos/master rev-parse
--abbrev-ref HEAD
master
$ /usr/bin/git -C /Users/shc_retina/.cocoapods/repos/master reset --hard
origin/master
HEAD is now at e1d350b456a [Add] MBRPaySDK 1.0.6
Analyzing dependencies
The color indicates what happens when you run `pod update`
<green> - Will be updated to the newest version
<blue> - Will be updated, but not to the newest version because of specified version in Podfile
<red> - Will not be updated because of specified version in Podfile
The following pod updates are available:
- SDWebImage 4.4.2 -> 4.4.2 (latest version 5.0.0-beta)
网友评论