Post

Replies

Boosts

Views

Activity

Reply to iOS 18 strange SwiftData fatal error
I can confirm that changing the code I replied with earlier, to the following code fixes the problem: var modelContainer: ModelContainer? init() { self.modelContainer = try? ModelContainer(for: Event.self) } @MainActor func fetchEvents() -> [Event] { guard let modelContainer = modelContainer else { return [] } let descriptor = FetchDescriptor<Event>(sortBy: [SortDescriptor(\.dateCreated, order: .reverse)]) guard let events = try? modelContainer.mainContext.fetch(descriptor) else { return [] } return events }
Sep ’24
Reply to iOS 18 SwiftData ModelContext reset
I have the exact same problem. Sometimes when I build and run the app, it crashes and shows me the error. This happens randomly . Sometimes it builds fine and sometimes it crashes. Also, when it crashes and I relaunch the app without building again, it never crashes again and all data is still there. I need to publish iOS 18 update to my app but I am not sure if it's safe. Have you been able to find a solution? I wonder if this is a bug in Xcode or there is a problem with my code.
Sep ’24
Reply to I Keep getting this error in my swift project.
I have the exact same problem. Sometimes when I build and run the app, it crashes and shows me the error. This happens randomly . Sometimes it builds fine and sometimes it crashes. Also, when it crashes and I relaunch the app without building again, it never crashes again and all data is still there. I need to publish iOS 18 update to my app but I am not sure if it's safe. Have you been able to find a solution? I wonder if this is a bug in Xcode or there is a problem with my code.
Sep ’24