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

问题描述 投票:0回答:3

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

我目前所做的是 -

我模拟崩溃,它创建了一个 myapp.plcrash 文件。

生成后,我在命令行上使用以下命令 -

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

这工作完美 - 但有没有一种方法我可以不必执行这个额外的步骤并直接从我的代码将其转换为 .crash 可能通过导入库或其他东西??

有什么解决办法吗???

iphone crash plcrashreporter
3个回答
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);
        }

    }

0
投票

您是否尝试过以新格式对 .crash 文件进行符号化?


0
投票

您可以在项目目录中运行plcrashutil main.m进程。

怎么样? enter image description here

然后,应在方案上选择 plcrashutil,您可以手动发送参数。

产品 > 方案 > 编辑方案 > plcrashutil

enter image description here

最后84.行代码中input_file = argv[0];而不是代码 input_file = argv1;应该写在plcrashutil目录下的main.m文件中

这样您就可以运行和调试代码。

© www.soinside.com 2019 - 2024. All rights reserved.