How to Keep Complications Up To Date 100% SwiftUI Independent Watch App?

The ‘Keep your complications up-to-date‘ WWDC20 session video used a kite flying app that was a WatchKit extension app. I’m planning on building a new 100% SwiftUI watch only (independent) app for watchOS 7 using Xcode 12 Beta and I’m wondering how I do complication updates in that case without the watch kit extension APIs used in the video session.

Accepted Reply

Well, I tried creating a new test project using Xcode 12 Beta and a Watch Only template for watchOS, and, except for the HostingController entry point being replaced by the App.swift entry point and the ExtensionDelegate.swift file being removed, it appears the new project is still a WatchKit app project. The project still has multiple targets including WatchKit App and WatchKit Extension targets. Therefore, it appears dealing with updating watch complications uses most/all of the same APIs that are used for the non-100% SwiftUI project template project from Xcode 11.

Replies

Well, I tried creating a new test project using Xcode 12 Beta and a Watch Only template for watchOS, and, except for the HostingController entry point being replaced by the App.swift entry point and the ExtensionDelegate.swift file being removed, it appears the new project is still a WatchKit app project. The project still has multiple targets including WatchKit App and WatchKit Extension targets. Therefore, it appears dealing with updating watch complications uses most/all of the same APIs that are used for the non-100% SwiftUI project template project from Xcode 11.
Create ExtensionDelegate file and in your App struct add this line:

Code Block
@WKExtensionDelegateAdaptor(ExtensionDelegate.self) var delegate