i am trying to create complication for watchOS2. I have created new target for my iOS application - with Glances and Complications I want to have only one Modular Large Complication.
When I run trying to set complication Watch freezes (on both simulator and real Watch)
Here's my complication code:
-(void)getCurrentTimelineEntryForComplication:(CLKComplication *)complication withHandler:(void (^)(CLKComplicationTimelineEntry * _Nullable))handler {
if (complication.family == CLKComplicationFamilyModularLarge) {
CLKComplicationTemplateModularLargeColumns *template = [[CLKComplicationTemplateModularLargeColumns alloc] init];
NSString *title = NSLocalizedString(@"TODAYINTAKE", nil);
template.row1Column1TextProvider = [CLKSimpleTextProvider textProviderWithText:title];
template.row2Column2TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"kcal"];
template.row3Column2TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"ml"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([self isDateToday:[defaults objectForKey:@"dateSaved"]]) {
template.row2Column1TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"%@",[defaults objectForKey:@"energy"]];
template.row3Column1TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"%@", [defaults objectForKey:@"water"]];
} else {
template.row2Column1TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"0"];
template.row3Column1TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"0"];
}
template.row2ImageProvider = [CLKImageProvider imageProviderWithOnePieceImage:[UIImage imageNamed:@"energy64"]];
template.row3ImageProvider = [CLKImageProvider imageProviderWithOnePieceImage:[UIImage imageNamed:@"water64"]];
template.row1ImageProvider = [CLKImageProvider imageProviderWithOnePieceImage:[UIImage imageNamed:@"64"]];
template.row1Column2TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@" "];
CLKComplicationTimelineEntry *entry = [CLKComplicationTimelineEntry entryWithDate:[NSDate new] complicationTemplate:template];
handler(entry);
} else handler(nil);
}
-(void)getPlaceholderTemplateForComplication:(CLKComplication *)complication withHandler:(void (^)(CLKComplicationTemplate * _Nullable))handler {
if (complication.family == CLKComplicationFamilyModularLarge) {
CLKComplicationTemplateModularLargeTable *template = [[CLKComplicationTemplateModularLargeTable alloc] init];
NSString *title = NSLocalizedString(@"TODAYINTAKE", nil);
template.headerTextProvider = [CLKSimpleTextProvider textProviderWithText:title];
template.row1Column2TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"kcal"];
template.row2Column2TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"ml"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([self isDateToday:[defaults objectForKey:@"dateSaved"]]) {
template.row1Column1TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"%@",[defaults objectForKey:@"energy"]];
template.row2Column1TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"%@", [defaults objectForKey:@"water"]];
} else {
template.row1Column1TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"0"];
template.row2Column1TextProvider = [CLKSimpleTextProvider textProviderWithFormat:@"0"];
}
handler(template);
} else handler(nil);
}
i am passing CLKComplicationTimeTravelDirectionNone
as supported time travel directions
I am helpless since i am can't see any error in console and simulator or device just freezes.
From Carousel crash report I was able to read this information:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application is required. bundleID: ql.ManaEU.watchkitapp appToReplace: proxy: ql.ManaEU.watchkitapp <(null) Not found in database>' terminating with uncaught exception of type NSException abort() called CoreSimulator 191.4 - Device: Apple Watch - 42mm - Runtime: watchOS 2.0 (13S343) - DeviceType: Apple Watch - 42mm