Post

Replies

Boosts

Views

Activity

SwiftData multiple Models - Thread 1: "NSFetchRequest could not locate an NSEntityDescription for entity name 'PastTripData'"
It works fine if I take either model out, but it doesn't work with both I have tried multiple variations import SwiftData import Foundation @main struct blendTravelfourApp: App { @Environment(\.modelContext) var context var body: some Scene { WindowGroup { ContentView() .modelContainer(for: PlanTripData.self) .modelContainer(for: PastTripData.self) } } } import SwiftData @main struct blendTravelfourApp: App { var container: ModelContainer init() { do { let config1 = ModelConfiguration(for: PlanTripData.self) let config2 = ModelConfiguration(for: PastTripData.self) container = try ModelContainer(for: PlanTripData.self, PastTripData.self, configurations: config1, config2) } catch { fatalError("Failed to configure SwiftData container.") } } var body: some Scene { WindowGroup { ContentView() .modelContainer(container) } } }
2
4
1.1k
Jan ’24