Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 15 Beta 8: WidgetKit #Preview Macro stopped working:

Did something change as far as how to use #Preview macros in Xcode 15 Beta 8? This code used to work fine but now no longer compiles because of == PREVIEW UPDATE ERROR: CompileDylibError: Failed to build WatchRecoveryWidget.swift Compiling failed: cannot convert value of type 'WatchRecoveryScoreTimeLineEntry' to closure result type 'any View'

  #Preview(as: WidgetFamily.accessoryRectangular) {
    WatchRecoveryScoreWidget()
} timeline: {
    WatchRecoveryScoreTimeLineEntry(date: Date(), recoveryScore: 75, subscriptionIsActive: true)
}
like image 552
GarySabo Avatar asked May 25 '26 17:05

GarySabo


1 Answers

I was able to address this issue by adding @available(iOS 17.0, *) above each my of previews. Not sure why the error it shows is so misleading, but hopefully that gets addressed in a future Xcode 15 update.

So your preview would look like this now:

@available(iOS 17.0, *)
#Preview(as: .accessoryRectangular) {
    WatchRecoveryScoreWidget()
} timeline: {
    WatchRecoveryScoreTimeLineEntry(date: .now, recoveryScore: 75, subscriptionIsActive: true)
}

like image 75
eschos24 Avatar answered May 27 '26 19:05

eschos24



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!