ioswatchkitwidgetkitapple-watch-complicationxcode14

How to Edit Complication name in Watch app of iPhone?


I am trying to create a WidgetKit based complication for watchOS 9 on XCode 14. Everything works fine but the Complication name in the Watch app of the iPhone shows COMPLICATION_TYPE_EDIT_LABEL_(NULL)_COMPANION

How do I change it to display my app's name?

Steps to reproduce : Create a new project on Xcode 14 -> Add new Watch App Target -> Add new Widget Extension target for watchOS.

enter image description here


Solution

  • There is a solution. It comes from ClockKit framework. It’s not mentioned in new APIs, but it works. In your watchOS target create file ComplicationController.swift with the following content:

    import ClockKit
    class ComplicationController: NSObject, CLKComplicationDataSource {
        func complicationDescriptors() async -> [CLKComplicationDescriptor] { [] }
        func currentTimelineEntry(for complication: CLKComplication) async -> CLKComplicationTimelineEntry? { nil }
    }
    

    Then add this field in the Info.plist of watchOS target:

    ClockKit Complication - Principal Class --> $(PRODUCT_MODULE_NAME).ComplicationController

    enter image description here

    The result: enter image description here

    I hope there will be a better solution later on, because now it's buggy and works not as it should be.