Looking over the documentation of NSURLSession and NSURLSessionConfiguration, I was under the impression I should configure it with a dictionary li
Based on all previous responses, this works for Swift 4, both HTTP and HTTPS:
let proxyHost = "127.0.0.1"
let proxyPort = 8888
let configuration = URLSessionConfiguration.default
configuration.connectionProxyDictionary = [
kCFNetworkProxiesHTTPEnable: true,
kCFNetworkProxiesHTTPProxy: proxyHost,
kCFNetworkProxiesHTTPPort: proxyPort,
kCFNetworkProxiesHTTPSEnable: true,
kCFNetworkProxiesHTTPSProxy: proxyHost,
kCFNetworkProxiesHTTPSPort: proxyPort
]
proxyHost should be a hostname and not contain any URL scheme.