How to setup SwiftUI app file to allow independent app to deploy on WatchOS 6

307 Views Asked by At

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". 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?

See the screenshot below. Thanks!

enter image description here

1

There are 1 best solutions below

0
kelin On

Please, check out official example: Developing a User Interface with SwiftUI. Basically you need to create storyboard-based interface and put a WKHostingController there (see InterfaceController.swift above). And there you will load SwiftUI view. You may also look at WWDC 2019 video #219: SwiftUI on watchOS.