我目前正在使用 PLCrashReporter,需要一些帮助来将 plcrash 直接转换为 .crash 文件,而不是使用 plcrashutil。
我目前所做的是 -
我模拟崩溃,它创建了一个 myapp.plcrash 文件。
生成后,我在命令行上使用以下命令 -
plcrashutil convert --format=iphone myapp.plcrash > app.crash
这工作完美 - 但有没有一种方法我可以不必执行这个额外的步骤并直接从我的代码将其转换为 .crash 可能通过导入库或其他东西??
有什么解决办法吗???
得到答案了
如果其他人正在寻找解决方案,这里是解决方案..
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);
}
}
您是否尝试过以新格式对 .crash 文件进行符号化?