I get this error : ModelContainer creation failed: SwiftDataError(_error: SwiftData.SwiftDataError._Error.loadIssueModelContainer, _explanation: nil) AbsGod/AbsGodApp.swift:25: Fatal error: Failed to create ModelContainer: The operation couldn’t be completed. (SwiftData.SwiftDataError error 1.)
when doing:
struct MyAppApp: App {
let container: ModelContainer
init() {
do {
let schema = Schema([
Workout.self,
Exercise.self
])
let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
container = try ModelContainer(for: schema, configurations: [modelConfiguration])
} catch {
print("ModelContainer creation failed: \(error)")
fatalError("Failed to create ModelContainer: \(error.localizedDescription)")
}
}
var body: some Scene {
WindowGroup {
TabBarView()
.tint(.red)
}
.modelContainer(for: [Workout.self, Exercise.self])
}
And I have no clue of how to resolve that. I saw similar issues with CloudKit, but I don't even have enabled it, just ticked Automatically manage signing in Signing & Capabilities of my project.
the relationship of my classes are defined like this, in a workout class having an array of exercises:
@Relationship(deleteRule: .cascade, inverse: \Exercise.workout) var exercises: [Exercise]? = []
and the inverse in the exercise class:
var workout: Workout?
I don't feel like the problem is coming from my classes, because when I try to reproduce the error on simpler project, everything works. it just won't create a modelContainder in my project and I have no idea what can makes that and the error is not really explicit...