6

アプリ内クラッシュ ログの作成を実装し、アプリがクラッシュしたときにユーザーから取得したいと考えています。そこで、PLCrashReport について調べて、自分のアプリに追加しようとしました。このフレームワークをダウンロードするために見つけたリンクがたくさんあります。Google コードGithubのように。

どのファイルをダウンロードすればよいか本当にわかりません。ある種のバイナリ リリース、ソース リリース、多数の PLCrashReporters が表示されます。

誰かが私のアプリに PLCrashReporter を追加する方法を指摘できますか?

前もって感謝します

4

1 に答える 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);
}
于 2012-12-26T18:21:09.740 に答える