Hi, did you manage to find a solution? I am experiencing the exact same problem now and I have no idea how to fix it. My GroupID is set correctly. Thank you.
Post
Replies
Boosts
Views
Activity
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.
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.
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
}