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???
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);
}
}
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