I have an iOS app with two targets: the main (the app), and a today extension widget. In the main target I have a class called "TimetablesInformation", and if I call a method of that class from the own target everything goes right. But if I tried to access to that class from the other target (the widget) with this:
TimetablesInformation *info = [[TimetablesInformation alloc] init];
[info getTimes:@"1" forLine:lineName];
it crashes with this code error:
2015-12-26 01:48:04.420 Closer Times[15689:307103] __extensionContextClass != nil -
/BuildRoot/Library/Caches/com.apple.xbs/Sources/libextension/libextension
82/libextension/Common/NSExtensionContext.m:164: Unable to find
NSExtensionContextClass (_NCWidgetExtensionContext) in extension bundle -
did you link the framework that declares the extension point?
TimetablesInformation is targeted to both targets on the right inspector of Xcode... So I have no clue about what can I be doing wrong... Could you help me, please?
EDIT: The getTimes method: -(NSArray *)getTimes:(NSString *)actualView forLine:(NSString *)lineName {
if ([actualView isEqual: @(1)]){
if ([lineName isEqual: @"Point A - Point B"]) {
self.workingDayTimesArray = @[@"07:00",@"07:30",@"08:00",@"08:30",@"09:00",@"09:30",@"10:00", @"10:30",@"11:00",@"11:30",@"12:00",@"12:30",@"13:00",@"13:30", @"14:00",@"14:30",@"15:00",@"15:30",@"16:00",@"16:30",@"17:00", @"17:30",@"18:00",@"18:30",@"19:00",@"19:30",@"20:00",@"20:30", @"21:00",@"21:30",@"22:00",@"22:30"];
}
}
I have tried with a void method, but I have the same error. If I call a method from the other target (main app) I haven't crashes, but if I do from my widget, yes I do. Have you an idea of the cause?
It means that you or somebody accidentally removed a framework or library from the target you're running.
In my case, I was getting this crash error when somebody removed NotificationCenter.framework from "Linked Frameworks and Libraries" in General tab or "Link Binary With Libraries" in Build Phases tab. Thus, to fix it, you just need to add it again and everything will work.
So when you re-created TodayExtension target it linked NotificationCenter.framework by default. That's why everything worked for you after this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With