Xcode 13 ignores GIT proxy settings when resolving SwiftPM packages (and probably for other SCM operations as well).

Number:rdar://FB9447729 Date Originated:2021-08-03
Status:Open Resolved:
Product:Xcode Product Version:13 beta 4
Classification:Incorrect/Unexpected Behavior Reproducible:Always
Please provide a descriptive title for your feedback:

Xcode 13 ignores GIT proxy settings when resolving SwiftPM packages (and probably for other SCM operations as well).

Which area are you seeing an issue with?

Please describe the issue:
This issue is seen with Xcode 13 beta 4 and all previous Xcode versions.

When working behind a proxy (which is common when working from home during the pandemic), XCode IDE built-in SCM does not work.

E.g. our Swift packages are stored in Azure Devops server, which is accessed via a corporate Proxy.

We configure the proxy settings in the user's .gitconfig file.

However, Xcode ignores this file when it tries to connect.

Please list the steps you took to reproduce the issue:

Just try to perform any SCM operation from within Xcode IDE when the SCM server must be accessed through a proxy.

What did you expect to happen?
Xcode must use .gitconfig (or the relevant environment variables) to determine that a proxy must be used.

What actually happened?
I debugged the problem and found out the following:

Xcode uses a helper service (com.apple.dt.Xcode.sourcecontrol.Git) to communicate with GIT servers. For that it uses the open source library libgit2.dylib (version 0.26.0)

When connecting to a remote GIT server, the service com.apple.dt.Xcode.sourcecontrol.Git calls libgit2 API git_remote_connect(...), where it passes a pointer to  git_proxy_options struct.

The struct git_proxy_options a type field with 3 possible values:

 * The type of proxy to use.
typedef enum {
	 * Do not attempt to connect through a proxy
	 * If built against libcurl, it itself may attempt to connect
	 * to a proxy if the environment variables specify it.
	 * Try to auto-detect the proxy from the git configuration.
	 * Connect via the URL given in the options
} git_proxy_t;

Xcode specifies GIT_PROXY_NONE.

I built a custom version of libgit2.dylib where I fixed the type to GIT_PROXY_AUTO, and resolution of packages started working from within Xcode IDE.


Thanks for describing your findings, I've recently run into this problem as well. If it's not too much trouble, would you be able to post a snippet or gist of your changes to fix the type to GIT_PROXY_AUTO? I wanted to do something similar and try to build a custom version of libgit2.dylib, and would appreciate seeing what you modified if it's not not that large of a changeset.

libgit2.dylib compiled after being modified. Don't forget to change the permissions. If you want to do it yourself, just leave your contact.


By tepmntharzjc at Jan. 12, 2022, 11:48 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!