Cannot Preview this file
Missing 'previewContext' modifier.
No bug anywhere else. Xcode 15, iOS 17
import SwiftUI
import WidgetKit
import SwiftData
struct DiemWidgetEntryView : View {
var entry: DiemWidgetEntry
// Used to work. I don't think it's the problem.
var body: some View {
let diem: Diem = .init(from: entry.configuration.diem)
DiemSharedView(diem: diem)
}
}
#Preview {
DiemWidgetEntryView(entry: DiemWidgetEntry(date: Date(), configuration: .christmas))
.previewContext(WidgetPreviewContext(family: .systemSmall))
.modelContainer(previewContainer) // works everywhere else in my project
}
Copy everything out of the file, delete it, and recreate it.
I had the same issue, the preview-block worked when I copied it to a different location though. Recreating the file worked.