问题描述
在Xcode中配置Watch扩展后,当运行iOS主应用时,Xcode弹出报错信息。


报错内容为:
This app was not built to support this device family; app is compatible with (
4
) but this device supports (
1
)
在Xcode中可以看到,这个应用实际上是Watch应用。

解决方案
在Xcode中点击“Product”-“Clean Build Folder Immediately”,清理数据后,关闭Xcode。

重新打开Xcode后,在Scheme中找到“Edit Scheme”功能。

在“Run”标签页中找到“Executable”,这里可以找到主应用。

可以看到,主应用的图标默认不是带有图标的,而是一个App Store Connect的图标,选中主应用后,点击“Close”按钮。
在Xcode中点击Scheme时,显示的下拉列表选择的是主应用,这时重新运行程序,不再显示报错。

如果想要运行Watch扩展,仍然可以在”Edit Scheme”中,选择Watch App。

总结
这里实际上还涉及一个Widget(小组件)不显示的问题,在另一篇《iOS不显示Widget(小组件)的问题》得到了解决。如果也存在Widget不显示/无法预览的问题,可以结合这篇文章来处理遇到问题。
修改Widget的配置后,可以在Scheme中查看到这三个Scheme。

相关文章
iOS不显示Widget(小组件)的问题:https://fangjunyu.com/2025/02/19/ios%e4%b8%8d%e6%98%be%e7%a4%bawidget%ef%bc%88%e5%b0%8f%e7%bb%84%e4%bb%b6%ef%bc%89%e7%9a%84%e9%97%ae%e9%a2%98/