Along this same thread the Coffee Tracker sample app's complication code is set for a deployment target of watchOS 6.2 and this is a code block for a complication from the sample;
Code Block | // Return a circular small template. |
| private func createCircularSmallTemplate(forDate date: Date) -> CLKComplicationTemplate { |
| // Create the data providers. |
| let mgCaffeineProvider = CLKSimpleTextProvider(text: data.mgCaffeineString(atDate: date)) |
| let mgUnitProvider = CLKSimpleTextProvider(text: "mg Caffeine", shortText: "mg") |
| |
| // Create the template using the providers. |
| let template = CLKComplicationTemplateCircularSmallStackText() |
| template.line1TextProvider = mgCaffeineProvider |
| template.line2TextProvider = mgUnitProvider |
| return template |
| } |
Changing the deployment target to watchOS 7.0 will produce this error:
'init()' was deprecated in watchOS 7.0: Initializing a template without parameters is deprecated in watchOS 7.0. Use an init with parameters instead.I have set up my own complications to supposedly align with the new init() requirements, however my complication is not showing up in the list of available options. Have I done something incorrect in this example?
Thank you - Dan
Code Block | func getLocalizableSampleTemplate(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTemplate?) -> Void) { |
| switch complication.family { |
| case .circularSmall: |
| let line1 = CLKSimpleTextProvider(text: "Run Roster") |
| let line2 = CLKSimpleTextProvider(text: "10 Sep 2021") |
| let circularSmall = CLKComplicationTemplateCircularSmallStackText(line1TextProvider: line1, line2TextProvider: line2) |
|
| handler(circularSmall) |
| ... // more switch cases below. |
|