Search code examples
objective-cxcodewatchkitapple-watch

watchOS Complication not showing as an option when customizing watch face


This is the first complication I have tried adding. I am adding it to a current project. I have managed to get it show up in the simulator, but not on my actual watch. It's just a SimpleImage complication so I am at a bit of a loss and I haven't found much online about this issue.

It shows under complications, but not as an option when customizing a watch face.

Here is my code below:

- (void)getSupportedTimeTravelDirectionsForComplication:(CLKComplication *)complication withHandler:(void(^)(CLKComplicationTimeTravelDirections directions))handler {
    //handler(nil);
    handler(CLKComplicationTimeTravelDirectionForward|CLKComplicationTimeTravelDirectionBackward);
}

- (void)getTimelineStartDateForComplication:(CLKComplication *)complication withHandler:(void(^)(NSDate * __nullable date))handler {
    handler(nil);
}

- (void)getTimelineEndDateForComplication:(CLKComplication *)complication withHandler:(void(^)(NSDate * __nullable date))handler {
    handler(nil);
}

- (void)getPrivacyBehaviorForComplication:(CLKComplication *)complication withHandler:(void(^)(CLKComplicationPrivacyBehavior privacyBehavior))handler {
    handler(CLKComplicationPrivacyBehaviorShowOnLockScreen);
}

#pragma mark - Timeline Population

- (void)getCurrentTimelineEntryForComplication:(CLKComplication *)complication withHandler:(void(^)(CLKComplicationTimelineEntry * __nullable))handler {
    // Call the handler with the current timeline entry
    handler(nil);
}

- (void)getTimelineEntriesForComplication:(CLKComplication *)complication beforeDate:(NSDate *)date limit:(NSUInteger)limit withHandler:(void(^)(NSArray<CLKComplicationTimelineEntry *> * __nullable entries))handler {
    // Call the handler with the timeline entries prior to the given date
    handler(nil);
}

- (void)getTimelineEntriesForComplication:(CLKComplication *)complication afterDate:(NSDate *)date limit:(NSUInteger)limit withHandler:(void(^)(NSArray<CLKComplicationTimelineEntry *> * __nullable entries))handler {
    // Call the handler with the timeline entries after to the given date
    handler(nil);
}

#pragma mark - Placeholder Templates

- (void)getLocalizableSampleTemplateForComplication:(CLKComplication *)complication withHandler:(void(^)(CLKComplicationTemplate * __nullable complicationTemplate))handler {
    handler(nil);
}

- (void)getPlaceholderTemplateForComplication:(CLKComplication *)complication withHandler:(void(^)(CLKComplicationTemplate * __nullable complicationTemplate))handler {

    if (complication.family == CLKComplicationFamilyCircularSmall){

        CLKComplicationTemplateCircularSmallSimpleImage *template = [[CLKComplicationTemplateCircularSmallSimpleImage alloc] init];

        UIImage *img = [UIImage imageNamed:@"Circular"];

        template.imageProvider = [CLKImageProvider imageProviderWithOnePieceImage:img];

        handler(template);

    } else  if(complication.family == CLKComplicationFamilyModularSmall) {

        CLKComplicationTemplateModularSmallSimpleImage *template = [[CLKComplicationTemplateModularSmallSimpleImage alloc] init];

        UIImage *img = [UIImage imageNamed:@"Modular"];

        template.imageProvider = [CLKImageProvider imageProviderWithOnePieceImage:img];

        handler(template);

    }

}

Solution

  • Complication can be added to watchface in two ways:

    1. On watch itself via force touch
    2. On iPhone via Watch application in Face Gallery section

    For both ways to work you should implement get​Localizable​Sample​Template(for:​with​Handler:​) method which will be called once to populate kind of placeholder while user will be choosing complications from the list.

    In order to make complication show up in Watch.app, you should additionally include special "complication bundle" to your project. This bundle will be stored in iOS app and Watch.app will find it when it will need to populate it's Face Gallery.