Hi friends,
Today I google for find out easiest way to get information about crashes, when they occur in iOS application. Apple provides a mechanism for it: iOS records crash logs on device, when you sync it with iTunes the logs are copied to the user's computer. This make lots of work for user, So I start to find out its alternative.
Today I google for find out easiest way to get information about crashes, when they occur in iOS application. Apple provides a mechanism for it: iOS records crash logs on device, when you sync it with iTunes the logs are copied to the user's computer. This make lots of work for user, So I start to find out its alternative.
At end I am able to found out a alternative of it. PLCrashReporter is "Plausible CrashReporter" is open source library develop Landon J Fuller. "It not just only creates a crash logs for you, But also makes it easy to tell the user about it the next time they start the application, and ask them if they'd like to email or upload the report back to developer"
Its working video
To integrate PLCrashReporter you have to follow the following steps.
- Download the PLCrashReporter source release.
- Navigate to the CrashReporter-iPhoneSimulator Target. Under the Build Settings: a) set "Perform Single-Object Prelink" to "No", b) set "Mach-O Type" to "Static Library".
- Select CrashReport-iPhoneSimulator : [IOS simulation (ie iPhone 4.3 Simulator)] and click build.
- Navigate to your build directory for the PLCrashReporter. For me, it was /Users/username/Library/Developer/Xcode/DerivedData/CrashReporter-(random characters)/Build/Products/Debug-iphonesimulator.
- Copy the libCrashReporter-iphonesimulator.a from the build directory in step 4 to the iphone application project directory you want to add the crash reporter to.
- Open the your iphone application project in xcode.
- Download the PLCrashReporter binary release and extract the framework to a local directory.
- Add the CrashReporter framework to your project.
- Following the same procedure as step 9, add the libCrashReporter-iphonesimulator.a static library to the "Link Binary with Libraries" section of the build phases. No *.framework directory is needed when adding a static library.
- 10. Review the "Link Binary with Libraries" in the Target. Make sure the libCrashReporter-iphonesimulator.a is listed above the CrashReporter framework. You can drag and drop to reorder.
Coding part.
Reference :
// 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);
}
/**
* 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;
I want backtrace via PLCrahsreport. What are steps should be taken.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHi mandeep. How to send crash logs via Email to developer.
ReplyDeleteIts not working for me on simulator. I doesn't come to "handleCrashReport" method after crashing and then restarting.
ReplyDeleteI tested your project sample.
ReplyDelete