I have followed those steps to solve the problem.
- set git HTTP proxy
git config --global http.proxy http://0.0.0.0:1087
git config --global http.proxy socks5://0.0.0.0:1080
- set ssh proxy for host
Append those lines at the end of ~/.ssh/config to add a socks5 proxy
Host github.com
ProxyCommand nc -X 5 -x 0.0.0.0:1080 %h %p
- use xcodebuild command to resolve package dependencies
Remember you must add the -scmProvider system option to force xcodebuild to use system git and git configurations, or it will use the xcode built-in git which will never go through the proxy.
xcodebuild -resolvePackageDependencies -scmProvider system
Some references here: