ios - 如何在我的应用程序中添加 PLCrashReporter?

标签 ios crash plcrashreporter

我想实现应用内崩溃日志的创建,并在应用崩溃后从用户那里获取它。所以,我查看了 PLCrashReport 并尝试添加到我的应用程序中。我找到了很多下载这个框架的链接。喜欢Google code , Github .

我真的不知道应该下载哪个文件。它显示了某种二进制版本、源代码版本、大量 PLCrashReporters..

有人可以指出在我的应用程序中添加 PLCrashReporter 的方法吗?

提前致谢

最佳答案

展示了如何集成 PLCrashReporter 的示例 here (archived) :

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

关于ios - 如何在我的应用程序中添加 PLCrashReporter?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13815395/

相关文章:

ios - 如何在swift中实现监听器模式

button - 单击显示按钮时应用程序崩溃,没有红色代码

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

ios - Atos 没有正确地符号化系统框架/库

iphone - 如何检查UIDatePicker中的日期是否被修改?

ios - Facebook SDK for IOS、Swift - 使用多个目标、不同的包标识符等

构建时的 iOS App 模块化

java - 如何调查 JVM 崩溃的原因?

memory-management - 如何解决 iOS 6 上 Map 的内存问题

stack-trace - PLCrashReporter : Creating a human readable stacktrace