I do really think the container is not correctly initiated yet at that point? Initializing the container prior to passing it in seems to fix it, like so:
@main
struct MyApp: App {
let modelContainer: ModelContainer
init() {
do {
modelContainer = try ModelContainer(for: Item.self)
} catch {
fatalError("Could not initialize ModelContainer")
}
}
var body: some Scene {
WindowGroup {
ContentView()
}
.modelContainer(modelContainer)
}
}
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: