9

I am currently working with PLCrashReporter and need some help with converting the plcrash directly to .crash file instead of using the plcrashutil.

What i currently do is -

I simulate a crash and it creates a myapp.plcrash file.

Once that is generated i use the following on command line -

plcrashutil convert --format=iphone myapp.plcrash > app.crash

This works perfectly - But is there a way I can dont have to do this extra step and convert it to .crash directly from my code probably by importing the library or something??

Any Solutions???

vivianaranha
  • 2,781
  • 6
  • 33
  • 47

2 Answers2

17

Got the answer

Here is the solution if anyone else is looking for it..

PLCrashReportTextFormat textFormat = PLCrashReportTextFormatiOS;


    /* Decode data */

    PLCrashReport *crashLog = [[PLCrashReport alloc] initWithData: data error: &error];
    if (crashLog == nil) {
        NSLog(@"Could not decode crash file :%@",  [[error localizedDescription] UTF8String]);
    } else {
        NSString* report = [PLCrashReportTextFormatter stringValueForCrashReport: crashLog withTextFormat: textFormat];
        NSLog(@"Crash log \n\n\n%@ \n\n\n", report);

        NSString *outputPath = [documentsDirectory stringByAppendingPathComponent: @"app.crash"];
        if (![report writeToFile:outputPath atomically:YES encoding:NSUTF8StringEncoding error:nil]) {
            NSLog(@"Failed to write crash report");
        } else {
            NSLog(@"Saved crash report to: %@", outputPath);
        }

    }
vivianaranha
  • 2,781
  • 6
  • 33
  • 47
0

Have you tried to symbolicate the .crash file in the new format?

imobilizer
  • 161
  • 1
  • 13