capacitor icon indicating copy to clipboard operation
capacitor copied to clipboard

[Bug]: Xcode 16.3 simulator bug causes network access to fail?

Open khaelou opened this issue 9 months ago • 9 comments

Capacitor Version

When testing on iOS 18.3.2 or beyond on iPad Air (5th generation) for example, we run into Network Connection issues which may be bypassed with a code alternative as mentioned by Paul Hudson

The change is URLSession.shared to URLSession(configuration: .ephemeral)

Other API Details

10.8.1 npm
v22.3.0 node

Platforms Affected

  • [x] iOS
  • [ ] Android
  • [ ] Web

Current Behavior

For example, connections to Firestore within a Ionic + Capacitor application halts / fails to connect when testing atleast iOS 18.3.2 on select devices; discovered with iPad Air 5th gen.

"Cloud Firestore could not connect to backend"

Expected Behavior

Naturally, connections should continue to occur yet being the nature of PWA's we as developers don't have direct access to the WebView.

Project Reproduction

https://github.com/khaelou/bare

Additional Information

Issue #8889 and Issue #14712 follow this issue directly, there is also an [ongoing thread](Network Connection Issue on Xcode 16.3 Simulator) on Apple Developer Forums (Apple Developer account required)

khaelou avatar Apr 14 '25 05:04 khaelou

I was able to temporarily solve this by changing URLSession.shared which limits WebView on iOS 18.3.2 and beyond 👍

khaelou avatar Apr 23 '25 06:04 khaelou

How and where?

ThatzOkay avatar May 02 '25 09:05 ThatzOkay

How and where?

In .node_modules/@capacitor/ios/Capacitor/Capacitor/WebViewAssetHandler.swift and .node_modules/@capacitor/ios/Capacitor/Capacitor/Plugins/CapacitorUrlRequest.swift with code

enum GenAIURLSession {
    static var `default`: URLSession {
        #if targetEnvironment(simulator)
        if #available(iOS 18.3.2, *) {
            return URLSession(configuration: .ephemeral)
        }
        #endif

        return URLSession.shared
    }
}

let urlSession = GenAIURLSession.default

then npx cap sync

khaelou avatar May 09 '25 22:05 khaelou

Thanks

ThatzOkay avatar May 09 '25 23:05 ThatzOkay

Has Xcode 16.4 fixed this bug? I'm assuming no, but hope springs eternal.

markemer avatar Jun 02 '25 14:06 markemer

I'm wondering if we should include a simulator workaround - do we know if there is an open radar bug with Apple? As WWDC is next week, I may schedule a session.

markemer avatar Jun 03 '25 18:06 markemer

@markemer well I also had to enable the CapacitorHTTP plugin for my workaround to work (a few steps needed for success in our app), even with the latest Xcode. It may be wise to schedule a session with Apple, unsure about the radar bug.

khaelou avatar Jun 06 '25 00:06 khaelou

Yeah, they were not super helpful at WWDC - but I'll see if I can break this in XCode/iOS 26 and I'll open a bug with them.

markemer avatar Jul 03 '25 19:07 markemer

do we know if this was fixed in xcode 26?

michaelknoch avatar Nov 19 '25 18:11 michaelknoch