PLCrashReporter - 如何在Xcode中直接将.plcrash转换为.crash并将其保存到本地

9

我目前正在使用PLCrashReporter,并需要一些帮助将plcrash直接转换为.crash文件,而不是使用plcrashutil。

我现在的做法是 -

模拟崩溃并生成myapp.plcrash文件。

一旦生成了该文件,我在命令行上使用以下命令 -

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

这个方法很完美 - 但是否有一种方法可以避免这一额外步骤,直接从我的代码中将其转换为.crash文件,可能通过导入库之类的方式?有什么解决方案吗?
2个回答

17

已经得到答案。

这是解决方案,如果有其他人正在寻找它..

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

    }

1
你在哪里对数据进行符号化? - ilker Acar
尝试了一段时间,这种新格式可以使用symbolicatecrash进行符号化,尽管它看起来与使用plcrashutils生成的崩溃文件不同。对于我的情况,我只需通过网络发送报告(无需发布二进制数据)。 - Walty Yeung
请添加Swift版本,vivianaranha。 - Qadir Hussain
我已经这样做了,但仍然没有显示错误的行号。 - Ehsan Razm khah

0

你尝试过在新格式中对.crash文件进行符号化吗?


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接