【发布时间】:2021-01-18 08:00:52
【问题描述】:
我使用新的闪亮的WidgetKit 制作了一个小部件。它看起来不错并且按预期工作。然后我将其所有逻辑放入单独的框架中,以在扩展程序和主应用程序之间共享常量值,并提供可单元测试的目标。在引入框架 SwiftUI 预览后停止工作。我收到错误消息:Cannot preview in this file - Could not find host for previews。 WidgetPreviewContext 似乎不起作用。我想知道为什么。会不会是因为我使用的是 macOS Catalina 10.15.6?
【问题讨论】:
-
什么是“诊断”?
-
如果它与我的错误相同,则诊断如下。你运气好吗@Artem?
"UnableToFindPreviewHostError<XcodeGraphSource>: Could not find host for previews Could not find a host (app, extension, framework) given the open files and active `PreviewProvider` types. Make sure the open files and `PreviewProvider` types are target in the active scheme." -
@MichaC。不好意思推迟了。是的,Neillnglis 提到了和我一样的诊断方法。到目前为止,我还没有进一步了解它。
标签: ios swiftui macos-catalina xcode12 widgetkit