[英]How to setup SwiftUI app file to allow independent app to deploy on WatchOS 6
I am attempting to deploy a SwiftUI app to an Apple Watch Series 2 with WatchOS 6.3, from an iPhone running iOS 15. After connecting the device to Xcode and clicking the build button, I get errors that indicate @SceneBuilder
, Scene
, WindowGroup
, and NavigationView
are only " only available in application extensions for watchOS 7.0 or newer".我正在尝试从运行 iOS 15 的 iPhone 将 SwiftUI 应用程序部署到带有 WatchOS 6.3 的 Apple Watch Series 2。将设备连接到 Xcode 并单击构建按钮后,我收到指示
@SceneBuilder
、 Scene
、 WindowGroup
和NavigationView
仅“仅在 watchOS 7.0 或更高版本的应用程序扩展中可用”。 Is there a way to configure this file (or some other part of the Xcode environment) to enable the app to work with WatchOS 6.3 or lower?有没有办法配置此文件(或 Xcode 环境的其他部分)以使应用程序能够与 WatchOS 6.3 或更低版本一起使用?
See the screenshot below.请参阅下面的屏幕截图。 Thanks!
谢谢!
Please, check out official example: Developing a User Interface with SwiftUI .请查看官方示例: Developing a User Interface with SwiftUI 。 Basically you need to create storyboard-based interface and put a
WKHostingController
there (see InterfaceController.swift above).基本上你需要创建基于故事板的界面并在那里放置一个
WKHostingController
(参见上面的 InterfaceController.swift)。 And there you will load SwiftUI view.在那里您将加载 SwiftUI 视图。 You may also look at WWDC 2019 video #219: SwiftUI on watchOS .
您还可以在 watchOS 上观看 WWDC 2019 视频 #219:SwiftUI 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.