3

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

1 Answers1

4

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.

mosariot
  • 171
  • 1
  • 6
  • Thanks, but it did not work for me. I have filed a bug report with Apple. Will share any updates when i get them. – Kamal Kumar Lakshmanan Oct 14 '22 at 15:44
  • Ok, that's strange. I've posted exact the same solution here https://developer.apple.com/forums/thread/717218, and it works for at least two more people. Maybe you can provide some additional information about your case? Because Apple is not so fast in solving that kind of issues. – mosariot Oct 15 '22 at 08:03
  • 1
    It works fine for me too. @KamalKumarLakshmanan make sure to add the controller file to the watchOS target. Also make sure the value in the Info.plist has the correct product module name, or the variable `$(PRODUCT_MODULE_NAME)`, followed by a dot and then the name of your class (without the (String type) at the end). The property for the Info.plist can be added directly from Xcode on the target properties, don't added in code. – vicegax Oct 15 '22 at 10:54
  • @mosariot Can I suggest to add a small screenshot of how the property would look on the `Info.plist` for clarity? – vicegax Oct 15 '22 at 11:19
  • @vauxhall Of course, I will add it. – mosariot Oct 15 '22 at 11:35
  • Finally, it worked for me. The screenshots helped. Thanks @vauxhall and mosariot . Still let's hope for a fix from Apple, so we don't have to do these extra steps. – Kamal Kumar Lakshmanan Oct 15 '22 at 17:03