Xcode14.3 Widget预览报错及App内可编辑Widget实现求助
SwiftUI Widget预览失败与App内可编辑Widget实现求助
环境与需求
- 零基础SwiftUI开发者,使用Xcode 14.3开发跨iOS、macOS的倒计时App
- 核心需求:App内每个倒计时事件以可配置的小型Widget形式展示,点击Widget可进入编辑界面
- 当前问题:无法在非模拟器环境下预览Widget或Widget上下文内容
项目结构
- 除
CountWidgetView外,所有文件均由Xcode自动生成 ContentView与当前Widget相关代码无关联
具体报错信息
1. CountWidgetView(目标成员:Propedium (App))
预览报错:
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 targets in the active scheme
2. PropediumWidgetMacOS(目标成员:PropediumWidgetMacOSExtension)
预览报错:
No plugin registered to launch the process type widgetExtension
已尝试的无效操作
- 为
PropediumWidgetMacOSExtension链接Intent.framework - 调整文件的目标成员归属
- 移除代码中的
@main标记
求助方向
- 解决上述两个Widget预览报错的具体方案
- 实现「App内可点击编辑的小型Widget」的替代技术方案
内容的提问来源于stack exchange,提问作者I7T5
相关产品推荐
相关产品推荐

