URLSession is broken in iOS 18.4 RC Simulator

This thread has been locked by a moderator; it no longer accepts new replies.

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.

@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?

I have the same issue. Strangely it appear for me only on iPad simulator (no matter which iPad model is chosen). On iPhone simulator it works without any problem.

I also get either the time out (endless loading), or parsing failure.

Still the same here with macOS 15.4.1 and XCode Simulator 16.0 (1042.1) Vision OS 2.4.

Workaround of disabling http/3 on the server side still works fine.

Should I report this separately?

Yes. This thread, and the resulting bugs, are about the core “URLSession doesn’t work in the simulator” issue. If you’re seeing a crash, that’s something else, something that needs its own bug report.

Please post your bug number, just for the record.

Share and Enjoy

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

3 weeks since thread is opened. Any changes?

When will this problem be solved and we get back a working iOS Simulator? Resorting to older Simulator versions is not an option for Apple Intelligence related code.

I am coming from react-native land, and here to report this issue is affecting hundreds/thousands of iOS apps. Even tho this issue is for simulator, I for some reason am failing App Review now, and the only thing I have been able to isolate that changed is 18.4. I haven't been able to reproduce on a device, and yet I am failing app review which apparently uses real devices, but they are seeing the network failure issues. I am skeptical if they are using real registered devices because of it

Here are all of the react-native dependencies who are completely blocked by this bug:

Just encountered this today for the first time, in an iOS 18.2 simulator that had previously worked.

I do think there was a preceding Xcode and simulator-set update, though.

The

request.assumesHTTP3Capable = false

workaround does not work for me.

According to the Capacitor.js team, this issue is also linked with my other report and causes disruption in my team: https://developer.apple.com/forums/thread/781454

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

Seems like it's fixed in Xcode 16.4 + iOS 18.5 Simulator Betas. 👌 I'm only testing it on macOS 15.3.2, tho, but at least there's a positive sign.

Appears to be fixed in Xcode 16.4 beta 1.

Cool. And, yeah, that matches my expectations.

Thanks for testing this so promptly (and likewise to misacek).

Share and Enjoy

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

How can Apple not have tested this fundamental scenario before releasing?

Just tested on Xcode Version 16.4 beta (16F1t) and iOS 18.5 simulator and the issue persist.

Hello ! Could we hope for a fix soon ? This is breaking one of our app main features on both simulators and real devices.

I tried to build the app locally using XCode 16.4 beta but I still have the same issues on iOS simulator (18.4).

Best regards.

visionOS 2.4 is even worse, completely useless. Works OK only for the first minute after installation. Craziest part is that Xcode 16.3 don't see visionOS lower than 2.4, so there's no roll back and visionOS development is basically not possible. Though, obviously no one cares about visionOS.

I messed up my live coding interview because of this.

I had to share my screen so the interviewer could see what I was doing, so I ran the simulator. only to end up showing them a pathetic developer who cannot make even a single image downloader from server, debugging network request within 1 hour. I hope this would be fixed in Xcode 16.4.

Thanks Apple.

Appears to be fixed now when using the Simulator 16.0 with iOS 18.5. At least I see http/3 working fine now from the iPhone and iPad in the simulator with my app and also with Safari.

Xcode 16.4 (16F6), iOS 18.4 Simulator - issue still exists

Xcode 16.4 (16F6), iOS 18.5 Simulator - issue resolved

Yeah, it's about the runtimes mainly. Let's pretend 18.3 and 18.4 Simulators never existed. 😄

The following warnings are alive and well on Xcode 16.4 (16F6) w/ iOS 18.5 simulator

URLSession is broken in iOS 18.4 RC Simulator
 
 
Q