如何在我的应用中添加PLCrashReporter?

6
我想实现应用程序崩溃日志的创建,并在应用程序崩溃时从用户那里获取它。因此,我查找了PLCrashReport并尝试将其添加到我的应用程序中。我发现有很多链接可以下载这个框架,比如Google codeGithub
我真的不知道该下载哪个文件。它显示了某种二进制发布、源发布、很多PLCrashReporter等。
有人能指出如何将PLCrashReporter添加到我的应用程序中吗?
谢谢!

在 GitHub 上找到你喜欢的活跃仓库,点击“Clone in Mac”或“Zip”。简单。所有道路都通向利润。 - CodaFi
这里的问题是找到原始的PLCrashReport。它显示了许多大小不同的PLCrashReporters。:( - Confused
谢谢您提供的信息。您能分享一些关于PLCrashReporter设置的链接吗? - Confused
1
将解压缩的zipball目录移动到您的项目目录中,然后将其Xcode项目添加为子项目,并链接框架。搜索此注释中的任何术语,应该会出现适当的子项目框架教程。 - CodaFi
测试命令行应用程序展示了基本的集成方法:http://code.google.com/p/plcrashreporter/source/browse/Source/Crash%20Demo/main.m 你应该考虑如何收集、符号化和分组输入数据。有多个开源框架和服务在PLCrashReporter之上,可以实现这些功能。 - Kerni
显示剩余2条评论
1个回答

10

如何集成PLCrashReporter的示例可以在这里(已存档)看到:

//
// Called to handle a pending crash report.
//
- (void) handleCrashReport {
    PLCrashReporter *crashReporter = [PLCrashReporter sharedReporter];
    NSData *crashData;
    NSError *error;
    // Try loading the crash report
    crashData = [crashReporter loadPendingCrashReportDataAndReturnError: &error];
    if (crashData == nil) {
        NSLog(@"Could not load crash report: %@", error);
        goto finish;
    }
    // We could send the report from here, but we'll just print out
    // some debugging info instead
    PLCrashReport *report = [[[PLCrashReport alloc] initWithData: crashData error: &error] autorelease];
    if (report == nil) {
        NSLog(@"Could not parse crash report");
        goto finish;
    }
    NSLog(@"Crashed on %@", report.systemInfo.timestamp);
    NSLog(@"Crashed with signal %@ (code %@, address=0x%" PRIx64 ")", report.signalInfo.name,
          report.signalInfo.code, report.signalInfo.address);
    // Purge the report
finish:
    [crashReporter purgePendingCrashReport];
    return;
}
// from UIApplicationDelegate protocol
- (void) applicationDidFinishLaunching: (UIApplication *) application {
    PLCrashReporter *crashReporter = [PLCrashReporter sharedReporter];
    NSError *error;
    // Check if we previously crashed
    if ([crashReporter hasPendingCrashReport])
        [self handleCrashReport];
    // Enable the Crash Reporter
    if (![crashReporter enableCrashReporterAndReturnError: &error])
        NSLog(@"Warning: Could not enable crash reporter: %@", error);
}

有没有关于如何在基于Cocoa的应用程序中使用框架的Mac OS X示例? - Ahmed
需要定义哪些头文件? - erdemgc
有需要导入的头文件吗?我已经在我的项目中添加了框架。但是,一旦我粘贴崩溃代码,它就会显示“使用未声明的标识符'PLCrashReporter'”。请帮忙... - manish_kumar
明白了。在这里找到了头文件:http://stackoverflow.com/questions/20540273/plcrashreporter-header-implementation - manish_kumar

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