Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add PLCrashReporter in my app?

I want to implement the in-app crash log creation and get it from the user once the app was crashed. So, I looked about PLCrashReport and tried to add in my app. There are so many links I found to download this framework. Like Google code, Github.

I really dont know which file I should download. It shows some kind of binary releas, source release, lots of PLCrashReporters..

Does someone can pointout the way to add the PLCrashReporter in my app?

Thanks in Advance

like image 293
Confused Avatar asked Dec 11 '12 07:12

Confused


1 Answers

An example of how to integrate PLCrashReporter was shown here (archived):

//
// Called to handle a pending crash report.
//
- (void) handleCrashReport {
    PLCrashReporter *crashReporter = [PLCrashReporter sharedReporter];
    NSData *crashData;
    NSError *error;
    // Try loading the crash report
    crashData = [crashReporter loadPendingCrashReportDataAndReturnError: &error];
    if (crashData == nil) {
        NSLog(@"Could not load crash report: %@", error);
        goto finish;
    }
    // We could send the report from here, but we'll just print out
    // some debugging info instead
    PLCrashReport *report = [[[PLCrashReport alloc] initWithData: crashData error: &error] autorelease];
    if (report == nil) {
        NSLog(@"Could not parse crash report");
        goto finish;
    }
    NSLog(@"Crashed on %@", report.systemInfo.timestamp);
    NSLog(@"Crashed with signal %@ (code %@, address=0x%" PRIx64 ")", report.signalInfo.name,
          report.signalInfo.code, report.signalInfo.address);
    // Purge the report
finish:
    [crashReporter purgePendingCrashReport];
    return;
}
// from UIApplicationDelegate protocol
- (void) applicationDidFinishLaunching: (UIApplication *) application {
    PLCrashReporter *crashReporter = [PLCrashReporter sharedReporter];
    NSError *error;
    // Check if we previously crashed
    if ([crashReporter hasPendingCrashReport])
        [self handleCrashReport];
    // Enable the Crash Reporter
    if (![crashReporter enableCrashReporterAndReturnError: &error])
        NSLog(@"Warning: Could not enable crash reporter: %@", error);
}
like image 186
snb Avatar answered Oct 26 '22 17:10

snb