URLSession bug in Xcode 16.3? Here’s a reliable workaround.

If a URLSession is created as shown below and the code is running on the simulator, the network connection may be lost or the request may time out.
1 |
let session = URLSession.shared |
This issue will affect all URLSession
clients only in simulator. Here is workaround for this:
1 2 3 |
let session: URLSession = { return URLSession(configuration: .ephemeral) }() |
Happy Coding 🙂