How can independent App make URL session requests through iPhone Proxy?

I have tried URL session requests in the following three ways:

Proxy through iPhone:

Request failure "ErrorDomain =NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline."

Connecting to a known network:

Request successful

Connecting using cellular data:

Request successful

These tests were all conducted on the Apple Watch Series 6 watchOS 9.4. Does "watch-only App "not support URL session request through iPhone Proxy?

Here is my current URL session request handler:

            let config = URLSessionConfiguration.ephemeral 
            config.waitsForConnectivity = true
            config.requestCachePolicy = .reloadIgnoringLocalCacheData
            config.urlCache = nil 
            config.allowsCellularAccess = true 
            config.allowsConstrainedNetworkAccess = true 
            config.allowsExpensiveNetworkAccess = true
            let session = URLSession(configuration: config, delegate: nil, delegateQueue: .main)
            let task = session.dataTask(with: url) { (data, response, error) in
                guard error == nil else {
                    print(error!)
                    self.error = "\(error!)"
                    return
                } 
            } 
            task.resume()

Info.plist

<key>NSAppTransportSecurity</key>
	<dict>
		<key>NSAllowsArbitraryLoads</key>
		<true/>
		<key>NSAllowsLocalNetworking</key>
		<true/>
	</dict>
Post not yet marked as solved Up vote post of jiaoxiaker Down vote post of jiaoxiaker
579 views

Replies

The same issue persists; a reboot of the iPhone can resolve it. However, requiring an iPhone reboot when installing and using Watch-Only apps on the watch creates a very poor user experience. It doesn't make sense to the users. I have posted a more detailed case here: https://developer.apple.com/forums/thread/749431