Search code examples
watchoswidgetkitapple-watch-complicationclockkit

Is it possible to have a ClockKit complications target and another WidgetKit complications target in the same workspace?


My app was originally an iOS app with a dependent watchOS extension. The watchOS extension used ClockKit complications. Recently, I started to upgrade the app:
I added a watch-only target based on SwiftUI. This works.
Now I want to migrate from my existing ClockKit complications in the dependent watch target to WidgetKit, but only for the new watch-only target.

I am reading Apple's Migrating ClockKit complications to WidgetKit. However I am a little worried by the remark

Important
After you add a WidgetKit extension to your project, the system tries to use it to generate complications for your watchOS app. As soon as your WidgetKit extension begins providing widget-based complications, the system disables your app’s ClockKit complications. It no longer wakes your app to call your CLKComplicationDataSource object’s methods to request timeline entries. However, the system may still wake your data source to call getWidgetConfiguration(from:completionHandler:), while migrating complications from ClockKit to WidgetKit.

Does this mean that, after I added a WidgetKit extension to my project workspace, the ClockKit complications for my dependent watch target won't work any longer? Or does this influence only my new watch-only target? Anyway, is it possible to have a ClockKit complications target and another WidgetKit complication target in the same workspace?


Solution

  • Yes, it is possible to have a ClockKit complications target and another WidgetKit complication target in the same workspace. If a WidgetKit Extension target is added, it can be embedded in the watch-only target, under target/<watch-only-target>/General/Frameworks, Libraries, and Embedded Content, using Name and Embed Without Signing.
    Afterwords, the dependent watch target and the watch-only target work as expected, i.e. the dependent target (Watch Extension) with a Complication Controller, and the watch-only target with the WidgetKit_Extension.