xcodebuild proxy settings

Hi,

I am trying to upload an app using xcodebuild from the command line from an automated build-server. This works perfectly when I am not behind a proxy, but my build-machine is behind the proxy and cannot turn it off. The build and upload also works fine from xcode-ui when the proxy is enabled.

My current proxy-settings are defined in the environment-variables http_proxy and https_proxy and are working for other command-line tools like curl and wget,

The proxy has its own certificate so I need the xcodebuild command to recognize both my proxy-settings and trust the certificate for the proxy.

When trying to upload, the process is stuck at the step "Authenticating with the App Store...", and finally quits with exit code 70:
Code Block
2020-11-12 13:00:51.355 xcodebuild[79720:561739] Starting upload
2020-11-12 13:00:51.457 xcodebuild[79720:561739] Progress 2 %: Extracting archive…
2020-11-12 13:00:51.557 xcodebuild[79720:561739] Progress 4 %: Creating App Store Connect API analysis file…
2020-11-12 13:00:54.420 xcodebuild[79720:561739] Progress 6 %: Authenticating with the App Store…
2020-11-12 13:09:42.466 xcodebuild[79720:562922] Progress 100 %: Authenticating with the App Store…
2020-11-12 13:09:42.467 xcodebuild[79720:562922] Progress 100 %: Completed App Store operation.
error: exportArchive: App Store Connect Operation Error. An error occurred uploading to the App Store.
Error Domain=WorkerErrorDomain Code=-10000 "error: App Store Connect Operation Error. An error occurred uploading to the App Store." UserInfo={NSLocalizedDescription=error: App Store Connect Operation Error. An error occurred uploading to the App Store.}
EXPORT FAILED
make: *** [ios-testflight] Error 70


When i run netstat -an|grep SYN during the upload, it shows that a tcp-connection is blocked by a firewall or something, wich i suppose is because of the proxy is not beeing used:

tcp4 0 0 10.0.16.193.61011 17.110.232.68.443 SYN_SENT
(17.110.232.68 is an ip owned by apple)



Is there any known way to solve this with the xcodebuild-command?

Accepted Reply

I have not found any "right" way of doing this, but I have found a working hack.

It turns out that xcode is embedding a Java Runtime wich is used for the upload. I replaced the java-executable with my own script that sets the proxy-values for the java process and importing my certificate to the keystore for the java-runtime.

Location of the java runtime:
/Applications/Xcode.app/Contents/SharedFrameworks/ContentDeliveryServices.framework/Versions/A/itms/java/bin/java

Location of the keystore:
/Applications/Xcode.app/Contents/SharedFrameworks/ContentDeliveryServices.framework/Versions/A/itms/java/lib/security/cacerts

The script I replaced the java-exec with (I first renamed the old executable: mv java java.real):

Code Block
#!/bin/bash
/Applications/Xcode.app/Contents/SharedFrameworks/ContentDeliveryServices.framework/Versions/A/itms/java/bin/java.real -Dhttps.proxyHost=<myproxyhost> $*

Remember to make the script executable (chmod a+x java)

This is a hack and might very well break in the future, but hopefully apple has fixed the proxy-issue by then.

Cheers.

Replies

I have not found any "right" way of doing this, but I have found a working hack.

It turns out that xcode is embedding a Java Runtime wich is used for the upload. I replaced the java-executable with my own script that sets the proxy-values for the java process and importing my certificate to the keystore for the java-runtime.

Location of the java runtime:
/Applications/Xcode.app/Contents/SharedFrameworks/ContentDeliveryServices.framework/Versions/A/itms/java/bin/java

Location of the keystore:
/Applications/Xcode.app/Contents/SharedFrameworks/ContentDeliveryServices.framework/Versions/A/itms/java/lib/security/cacerts

The script I replaced the java-exec with (I first renamed the old executable: mv java java.real):

Code Block
#!/bin/bash
/Applications/Xcode.app/Contents/SharedFrameworks/ContentDeliveryServices.framework/Versions/A/itms/java/bin/java.real -Dhttps.proxyHost=<myproxyhost> $*

Remember to make the script executable (chmod a+x java)

This is a hack and might very well break in the future, but hopefully apple has fixed the proxy-issue by then.

Cheers.

In the latest version of Xcode, you can simply edit the file /Applications/Xcode.app/Contents/SharedFrameworks/ContentDeliveryServices.framework/Versions/A/itms/java/conf/net.properties accordingly. After changing the following line (which is set to false by default), notarization was able to connect from behind out proxy server.

java.net.useSystemProxies=true