简体   繁体   中英

XCode Swift package manager error behind proxy

We use Swift package manager embedded in XCode for the dependencies in our project. Everything works fine when using it on the local machine. However when I try to build the project on our ci slaves I get the following error (when run from both XCode and the console) :

xcodebuild -resolvePackageDependencies

Resolve Package Graph

Fetching https://github.com/hmlongco/Resolver.git

xcodebuild: error: Could not resolve package dependencies:
  An unknown error occurred 

The difference between running it locally and on the ci slave is that the ci machines are configured behind a proxy. We already whitelisted all the URLs that were accessed when running this command, however the problem still persists. I couldn't find any detailed log about this error.

From examining the network packages sent when I run the command we can still see that some app is trying to access the direct URL instead of going through the proxy and here timeout is received. We only use public packages on github and there isn't any authentication needed.

From other side if the project is set up the old way using Package.swift and we run: swift package resolve the dependencies are successfully resolved without errors.

I have already gone through the following but there wasn't any helpful solution:

Configuration for enterprise networks
XCode proxy settings
SPM in real life projects
Same issue on developer forum
SSH error resolving dependencies - no ssh dependencies

Also there isn't any documentation about how resolving the packages through XCode is different than using 'swift package'. Currently I'm not sure whether it's possible to configure something so XCode uses the proxy settings for SPM or the Xcode SPM through proxy is just not supported. Any ideas? Any help is appreciated!

From what I just found, at least for Xcode 12.4, there's -scmProvider option for xcodebuild:

-scmProvider  which implementation to use for Git operations (system/xcode)

If I guess it correctly, -scmProvider system would force xcodebuild use "system" git. That, in turn, in my case, makes it respect the git config settings I have, particularly proxies.

Hence, answering the original question, it's probably worth trying

xcodebuild -resolvePackageDependencies -scmProvider system

(as long as Git config is properly set up)

Turns out there was an easy fix if we just configure the proxy for using it with git:

Getting Git to work with a proxy server - fails with "Request timed out"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM