How to add PLCrashReporter in my app?
Asked Answered
M

1

6

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

Madrigalist answered 11/12, 2012 at 7:17 Comment(7)
Find an active repo you like on GH, click "Clone in Mac", or Zip. Simple. All roads point to profit.Outguess
The problem here is finding the original PLCrashReport.It shows lots and lots of PLCrashReporters with various size. :(Madrigalist
It depends on your personal preference. If you want the bleeding edge, or the first party component, then go with the Google Code download, else, just pick a GitHub repo and download that sucker. They're all PLCrashReporter, just at various stages of development.Outguess
Thank you for the info. Can you share any link that gives the information about the set-up for PLCrashReporter?Madrigalist
Move the unzipped-zipball directory into your project's directory, then add it's Xcode project as a subproject, and link against the framework. Google any of the terms in this comment, and a suitable tutorial for subproject frameworks should come up.Outguess
Is there any official site available that demonstrate how to add the PLCrashReporter in our app?Madrigalist
The test command line app shows how to basically integrate it: code.google.com/p/plcrashreporter/source/browse/Source/… You should think about how you want to collect, symbolicate and group the incoming data. There are multiple open source frameworks and services on top of PLCrashReporter that do various of those things.Kerch
D
10

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);
}
Danais answered 26/12, 2012 at 18:21 Comment(4)
Any example for mac os x please? as to how to use framework in the cocoa based apps ?Pennant
what are header files need to be defined?Elsa
Are there any header files to be imported? I have added the framework in my project. But As soon as I paste the code for crash, it shows "Use of undeclared identifier 'PLCrashReporter'". Please help..Mccraw
Got it. Found out the header here : #20540773Mccraw

© 2022 - 2024 — McMap. All rights reserved.