katzer / cordova-plugin-local-notifications

Cordova Local-Notification Plugin
Apache License 2.0
2.56k stars 1.75k forks source link

Build Failed for iOS #68

Closed jlubean closed 10 years ago

jlubean commented 10 years ago

I ran "cordova plugin add https://github.com/katzer/cordova-plugin-local-notifications.git" from my project directory successfully. Then I added the following to the config.xml: . Then I ran "cordova build ios" and got a "BUILD FIELD" error (see below). What can I do to troubleshoot and fix this? I am running the build on Mac OSx 10.7.5 (Intel Core 2 Duo), Cordova 3.1.0, Xcode 4.6.2.

Here is the output from running "cordova build ios":

Generating config.xml from defaults for platform "ios" Preparing ios project Compiling app on platform "ios" via command "/Users/jlubean/dev/MyApp/platforms/ios/cordova/build" [Error: An error occurred while building the ios project.\ BUILD FAILED **

The following build commands failed: CompileC build/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/armv7/APPLocalNotification.o MyApp/Plugins/de.appplant.cordova.plugin.local-notification/APPLocalNotification.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler (1 failure) \ BUILD FAILED **

The following build commands failed: CompileC build/MyApp.build/Debug-iphonesimulator/MyApp.build/Objects-normal/i386/APPLocalNotification.o MyApp/Plugins/de.appplant.cordova.plugin.local-notification/APPLocalNotification.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler

katzer commented 10 years ago

Sorry but no idea. Maybe Xcode or Mac OS is to old.

jlubean commented 10 years ago

I tried to do a build from Xcode and I got some more information. Here are the errors:

Any ideas?

jlubean commented 10 years ago

I noticed that on line 162 (which does not have an issue in XCode) of APPLocalNotification.m, you have this:

[repeatDict setObject:[NSNumber numberWithInt:NSWeekCalendarUnit]  forKey:@"weekly"];

I wonder if lines 160-164 should be the following:

[repeatDict setObject:[NSNumber numberWithInt:NSHourCalendarUnit]  forKey:@"hourly"];
[repeatDict setObject:[NSNumber numberWithInt:NSDayCalendarUnit]   forKey:@"daily"];
[repeatDict setObject:[NSNumber numberWithInt:NSWeekCalendarUnit]  forKey:@"weekly"];
[repeatDict setObject:[NSNumber numberWithInt:NSMonthCalendarUnit] forKey:@"monthly"];
[repeatDict setObject:[NSNumber numberWithInt:NSYearCalendarUnit]  forKey:@"yearly"];
jlubean commented 10 years ago

I tried that and it worked!

katzer commented 10 years ago

The constants are marked as deprecated in newer versions.

Does that work for you too?

- (NSMutableDictionary*) repeatDict
{
    NSMutableDictionary* repeatDict = [[NSMutableDictionary alloc] init];

#ifdef NSCalendarUnitHour
    [repeatDict setObject:[NSNumber numberWithInt:NSCalendarUnitHour]  forKey:@"hourly"];
    [repeatDict setObject:[NSNumber numberWithInt:NSCalendarUnitDay]   forKey:@"daily"];
    [repeatDict setObject:[NSNumber numberWithInt:NSWeekCalendarUnit]  forKey:@"weekly"];
    [repeatDict setObject:[NSNumber numberWithInt:NSCalendarUnitMonth] forKey:@"monthly"];
    [repeatDict setObject:[NSNumber numberWithInt:NSCalendarUnitYear]  forKey:@"yearly"];
#else
    [repeatDict setObject:[NSNumber numberWithInt:NSHourCalendarUnit]  forKey:@"hourly"];
    [repeatDict setObject:[NSNumber numberWithInt:NSDayCalendarUnit]   forKey:@"daily"];
    [repeatDict setObject:[NSNumber numberWithInt:NSWeekCalendarUnit]  forKey:@"weekly"];
    [repeatDict setObject:[NSNumber numberWithInt:NSMonthCalendarUnit] forKey:@"monthly"];
    [repeatDict setObject:[NSNumber numberWithInt:NSYearCalendarUnit]  forKey:@"yearly"];
#endif

    [repeatDict setObject:[NSNumber numberWithInt:0]                   forKey:@""];

    return repeatDict;
}
jlubean commented 10 years ago

Yes, that code works. Thanks.

katzer commented 10 years ago

acb59dd97689c0cdf16d26aae9f1d554fe4107a1