WidgetPreviewContext is not working in a framework

1.1k Views Asked by At

I made a widget using new and shiny WidgetKit. It looks good and working as expected. Then I put all its logic into separate framework to share constant values between extension and main app as well as to provide a unit-testable target. And after introducing a framework SwiftUI previews stopped working. I'm getting error: Cannot preview in this file - Could not find host for previews. It seems that WidgetPreviewContext is not working. I'm wondering why. Could it be because I'm on macOS Catalina 10.15.6?

1

There are 1 best solutions below

0
On

I fixed this because I guess some of the files I had open in the workspace wasn't part of the same target?

Anyways I fixed this error by closing all files I had open in Xcode except the SwiftUI Code.