URLSession is broken in iOS 18.4 RC Simulator

I'm seeing fully reproducible issues with URLSession on iOS 18.4 RC Simulator running from Xcode 16.3 RC. URLSession seems to get into a broken state after a second app run. The following sample succeeds in fetching the JSON on first app run but when the app is closed and ran again it fails with one of these errors:

  • Error: Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost."
  • Error: Error Domain=NSURLErrorDomain Code=-1001 "The request timed out."

I'm wondering if this something related to my OS setup or is this due to internal URLSession changes in iOS 18.4. Already submitted as FB17006003.

Sample code attached below:

import SwiftUI

@main
struct NetworkIssue18_4App: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

struct ContentView: View {
    @State private var message: String = ""

    var body: some View {
        VStack {
            Text(message)

            Button("Try Again") {
                Task {
                    await fetch()
                }
            }
        }
        .task {
            await fetch()
        }
    }

    private func fetch() async {
        message = "Loading..."
        let url = URL(string: "https://poetrydb.org/title/Ozymandias/lines.json")!
        let session = URLSession.shared
        do {
            let response = try await session.data(from: url)
            print("Response: \(response)")
            message = "Success, data length: \(response.0.count)"
        } catch {
            print("Error: \(error)")
            message = "Error: \(error.localizedDescription)"
        }
    }
}
Answered by jhowlin in 837411022

Good news: Appears to be fixed in Xcode 16.4 beta 1.

So are you saying the fix for this issue is to setup the Charles Proxy on our iOS xCode simulators to "fix" this issue with 18.4 simulators? I would hope that this would be a very short term solution!!

So are you saying the fix for this issue is to setup the Charles Proxy

No. I offered a technical explanation as to why Charles masks this issue.

Share and Enjoy

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

Same here and even the builtin Safari.app inside the VisionOS 2.4 of Simulator 16.0 fails.

Since AsyncImage is having the same issues, how can we try some of the UrlSession configuration changes mentioned in previous posts? Is there a way to override the URLSession settings it uses?

Experiencing the same issue. First login works, second time it doesn't. I use a magic link to login, so the login process completely brakes down because 1. the simulator can't call the proper URL and 2. I can't navigate to the magic link URL.

I downgraded to 18.3 Simulator and things are working, so at least I can keep testing there.

Since AsyncImage is having the same issues, how can we try some of the UrlSession configuration changes mentioned in previous posts?

AFAIK AsyncImage doesn’t offer that level of customisation )-:

I downgraded to 18.3 Simulator and things are working

Yep. That’s certainly an easy way around this, just as long as you don’t rely on the simulator to explore any 18.4-specific features.

Share and Enjoy

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

I've read above about the issue being related to http/3 and indeed, disabling http/3 on the server side is a workaround. http/2 and older works fine.

I don't know if my issue is related. Looks like yes, but... I have a server with a domain name xxx.yyy.zzz.local which is located at the office, so I use Cisco AnyConnect to get there. On previous macOS and Xcode, everything worked fine. I was able to open the address in Safari on both macOS and iOS Simulator, and connect to it from an iOS app run by this simulator. Now, after updating to macOS 15.4 and Xcode 16.3, only macOS Safari works. The simulator doesn’t. Safari there just stalls with a white page and loading indicator, and the app output in the console this:

{_kCFStreamErrorCodeKey=-72000,
NSUnderlyingError=0x600000c74bd0 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={
_kCFStreamErrorDomainKey=10,
_kCFStreamErrorCodeKey=-72000,
_NSURLErrorNWResolutionReportKey=Resolved 0 endpoints in 16ms using unknown from query, _NSURLErrorNWPathKey=satisfied (Path is satisfied), interface: en0[802.11], uses wifi}}, 
_NSErrorFailingURLKey=https://xxx.yyy.zzz.local/rest/[some path],
_kCFStreamErrorDomainKey=10}

I tried installing other simulators(18.3, 17.5, 15.2), other Xcode(16.2), macOS(15.5 beta), nothing helps. It looks like the simulator can't find the host ip because mDNS ignores the .local address. Of course, using Charles helps because it redirects all traffic through itself, but that is not a solution. And it doesn't look like a problem with http/3, more like an issue with the simulator DNS resolver, if there is such.

i just updated xcode and download simulator iOS 18.4 but problem is networking Api are broken

This is sorta ridiculous where it developed. I've seen reports over Twitter, bunch of GitHub issues for Meta, Google SDKs, Flutter, RevenueCat… I wonder how this made it to a full release being known since almost the beginning.

I don't even think there's a usable method to escalate serious issues or blockers in the release train, unfortunately, nor an efficient way how Apple could communicate this. To this day, from the Dev portal it seems like if there are no issues at all, despite being the contrary.

Could we have some 1st-party communication from Apple regarding this, ideally on the Dev portal & Developer app (News section) or somewhere? This & other issues (StoreKit, UI crashes etc.) has a solid potential to ruin someone's day, now imagine somebody not noticing updating all self-managed CIs to latest releases and only after that finding out about it – whole pipeline red as a commies march & machine- + man-hours wasted. 🙃

@eskimo pls bump it up! 🙏

@eskimo pls bump it up!

AFAICK this bug already has sufficient priority. However, any fix lies in The Future™, and I can’t talk about that.

Share and Enjoy

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

Unrelated to direct use of Apple API's yet when testing a Firebase app (uses WebKit via Capacitor) on iPad Air (5th generation) on iOS 18.3.2+ this arises RPC Connection issues causing Cloud Firestore to not connect to backend hence our app failing Apple review process. It works on iOS 18.3.1 and below which makes me wonder how this was shipped to the public?

hence our app failing Apple review process.

This thread is about a problem in the iOS simulator. App Review tests your app on a real device, and this problem doesn’t show up there, so this is clearly a different issue.

Also, it seems like this is intimately tied to the third-party infrastructure you’re using. There’s not much we can do to help you out with that. I recommend that you raise this via the support channel for that infrastructure.

Share and Enjoy

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

This bug makes testing on simulators very hard. I had to reset the simulator 10 times just to capture some app screenshots. I hope it's being addressed with Super High priority

I’m encountering different behavior on the iOS 18.4 Simulator—a crash(EXC_BAD_ACCESS) when attempting to set proxyConfigurations like this:

let websiteDataStore = WKWebsiteDataStore.nonPersistent()
websiteDataStore.proxyConfigurations = [ProxyConfiguration]()

Not sure that it's the same issue, but the symptoms are similar. Should I report this separately?

URLSession is broken in iOS 18.4 RC Simulator
 
 
Q