So I have been trying to add a widget to my app. I am trying to add SwiftData to sync data from my app to the widget. My attempt at doing that is shown below:
import SwiftData
import SwiftUI
import WidgetKit
@main
struct CubeSpeedWidgetBundle: WidgetBundle {
let fullSchema = Schema([Time.self, Session.self])
let configuration = ModelConfiguration(schema: Schema([Time.self, Session.self]), inMemory: false, readOnly: false, cloudKitDatabase: .automatic)
var body: some Widget {
CubeSpeedWidget()
.modelContainer(try! ModelContainer(for: fullSchema, configurations: [configuration]))
CubeSpeedWidgetLiveActivity()
}
}
Xcode says that "Value of type 'CubeSpeedWidget' has no member 'modelContainer'". How should I do this properly?
Thanks.