Post

Replies

Boosts

Views

Activity

Composing Text Providers with  CLKTextProvider.​localizableTextProvider(​withStringsFileFormatKey:, textProviders:)
Are there any official examples of setting up a complication using localizableTextProvider(withStringsFileFormatKey:, textProviders:)? I can get the text provider to populate when producing a SampleTemplate, but whenever I try to generate a template using getTimelineEntries the text provider generated by localizableTextProvider the result is always blank, no text.Example (only supporting .utilitarianLarge):func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) { // Call the handler with the current timeline entry let template = CLKComplicationTemplateUtilitarianLargeFlat() template.textProvider = CLKTextProvider.localizableTextProvider( withStringsFileFormatKey: "testComplication", textProviders: [ CLKSimpleTextProvider(text: "Hello"), CLKSimpleTextProvider(text: "World") ] ) handler(CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)) }and sampleTemplate asfunc getLocalizableSampleTemplate(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTemplate?) -> Void) { // This method will be called once per supported complication, and the results will be cached switch complication.family { case .utilitarianLarge: let template = CLKComplicationTemplateUtilitarianLargeFlat() template.textProvider = CLKTextProvider.localizableTextProvider( withStringsFileFormatKey: "testComplication", textProviders: [ CLKSimpleTextProvider(text: "Hi"), CLKSimpleTextProvider(text: "World") ] ) handler(template) default: handler(nil) } }with ckcomplication.strings as"testComplication" = "%@ %@";The sample template will always display the text "Hi World", whereas the result from getCurrentTimelineEntry will always display an empty complication.Has anyone had luck composing text providers in this way?
2
0
2.2k
Jan ’21