[Pitch] Package Manager HTTP Proxy Configuration

[Pitch] Package Manager HTTP Proxy Configuration

Problem

Swift Package Manager uses Foundation's URLSession for downloading binary artifacts, fetching from package registries, downloading package collections, performing OCSP checks, and installing Swift SDKs. None of these operations respect HTTP proxy configuration — not environment variables, not system settings on Linux. This means developers behind corporate firewalls can swift package resolve source dependencies (which shell out to git) but cannot download a binary target from the same server.

The situation is worse in Xcode. Because Xcode launches from launchd with a minimal environment, there is no way to pass http_proxy to SPM operations initiated from the IDE. On macOS, the system proxy may be picked up implicitly by URLSession, but this behavior is undocumented, not portable, and provides no per-project override capability.

This affects everyone behind a corporate proxy, in government/university networks, or running CI behind a firewall — essentially anyone whose binary targets, registries, or collections are accessible only through a proxy.

Proposed Solution

We introduce a file-based proxy.json configuration, stored in SPM's existing configuration directories (~/.swiftpm/configuration/proxy.json for user-level, <project>/.swiftpm/configuration/proxy.json for project-level). New CLI commands (swift package config set-proxy, get-proxy, unset-proxy) manage the configuration. When present, proxy settings are applied to the URLSessionConfiguration used by SPM's HTTP client. When absent, macOS system proxy continues to work as a fallback — no behavior change for users who don't need this.

The config file approach works uniformly across CLI, Xcode, and CI regardless of environment variable availability.

Links

4 Likes