Xcode 14 and proxies

Hi,

Many developers are working behind a company proxy and Xcode doesn't seem to pick up the system's settings (either with automatic or manual configuration). It makes it impossible to use SPM as Xcode is not able to fetch dependencies, getting very regularly the error message "No Route to host (-1)".

I came across some workaround like changing the java config to use the system's settings or modifying the java exec used by Xcode to specify the proxy, but Xcode 14 doesn't seem to use java anymore (or at least I can't find where the config is located now).

I also tried to set the JAVA_TOOL_OPTIONS env variable with my proxy details and with java.net.useSystemProxies=true, with no luck.

Is there any way to configure the proxy within Xcode ? As anyone managed to make Xcode and SPM work behind a company proxy?

I'd really appreciate some help. Thanks!

Answered by nargarus in 737869022

What now always works for me now is (after weeks of real pain with SPM behind a corporate proxy):

On the terminal xcodebuild -scmProvider system -resolvePackageDependencies -disablePackageRepositoryCache -workspace MyProject.xcworkspace -scheme MyScheme

On XCode after the xcodebuild finishes XCode - File - Packages - Resolve Package Versions.

I hope this is of any help.

Is there any way to configure the proxy within Xcode?

Xcode has many different subsystems. Not all of these subsystems use the same networking infrastructure, and thus you’ll find that different subsystems respond to different proxy settings. So, the Java configuration options you referenced may work just fine for the Xcode subsystems that use Java, but they won’t necessarily work for SwiftPM.

My understanding is that the issue with the Git subsystem, which is what’s affecting SwiftPM, is a known issue (r. 36287120). I believe that you can work around this by using SwiftPM directly from the command line, rather than through Xcode, but that clearly doesn’t satisfy all use cases.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

@eskimo, can you link the issue 36287120 please ? I can't find it.

I already tried using SwiftPM from the command line, but it doesn't solve the problem. For example, even though I run successfully xcodebuild -resolvePackageDependencies -scmProvider system from the command line, it's not picked up by xcode. Therefore Xcode isn't able to compile my app...

When looking into the derived data, the command line produces a different folder than Xcode, which explains why it's not linked to Xcode. Am I missing something ? I don't find anything in xcodebuild's documentation that would mention anything else about resolvePackageDependencies.

can you link the issue 36287120 please ?

That’s not publicly visible )-: My Bug Reporting: How and Why? post has an explanation for why I post bug numbers even though you can’t read them.

Am I missing something?

No. That’s kinda what I meant when I said that “doesn’t satisfy all use cases”. You can use SwiftPM directly from the command line, which is what I was referring to. You’ve also found a way to use xcodebuild, which is neat (I didn’t know about that). The problem here is using the Xcode GUI.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

What now always works for me now is (after weeks of real pain with SPM behind a corporate proxy):

On the terminal xcodebuild -scmProvider system -resolvePackageDependencies -disablePackageRepositoryCache -workspace MyProject.xcworkspace -scheme MyScheme

On XCode after the xcodebuild finishes XCode - File - Packages - Resolve Package Versions.

I hope this is of any help.

I also use the xcodebuild -scmProvider system -resolvePackageDependencies workaround and it's usually enough.

But there is also XCode - File - Add Packages. When I put a public repo URL into the search field, I immediately get "The remote repository could not be accessed" dialog asking for authentication credentials. Proxy credentials won't work there. I don't have any better solution than switching to a proxy-free infrastructure in this case.

We're having the same issue with Xcode - File - Add Packages in my company. Was there any update regarding the radar or this issue? Is this maybe working in Xcode 15?

Xcode 14 and proxies
 
 
Q