TL: DR
Use a physical iPhone or an older simulator if you are having trouble using the latest iOS 18.4 simulator parsing data.
Background
I am working on an iOS app that uses Firebase Hosting for my json files and images, I want to load the data and cache them in SwiftData. In the beginning I thought Firebase Hosting works great for me, simple firebase deploy is all that needed to keep the files updated, no more git commits for Github pages where I used to store the files.
But, there can be problem with Firebase Hosting CDN caching the files, so it is best the set firebase no-cache.
Then in my iPhone 16 Pro iOS 18.4 simulator, I noticed that the json data could not be parsed. I tried with several simulators of iOS 18.4, all have the same problem. But there is no problem of fetching and parsing data when I use a physical iPhone with iOS 18.4.
Research
Later I find out that this is a known issue with the latest macOS and iOS simulators, especially with Xcode 15.3+ and macOS Sonoma.
My simulator logs show:
• network connection was lost
• no local endpoint
• Server protocol violation
• SwiftData warning about ModelContext on the wrong thread
• It fails on the macOS target or newer iOS simulators, but works fine on older simulators like iOS 18.0 / iPhone 12 Pro.
Solution
So now I stick with the iPhone 12 Pro simulator on iOS 18.0 while Apple and Firebase resolve the instability on newer platforms.