[Bug]: Xcode 16.3 simulator bug causes network access to fail?
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)
I was able to temporarily solve this by changing URLSession.shared which limits WebView on iOS 18.3.2 and beyond 👍
How and where?
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
Thanks
Has Xcode 16.4 fixed this bug? I'm assuming no, but hope springs eternal.
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 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.
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.
do we know if this was fixed in xcode 26?