我使用Flurry用的UncaughtExceptionHandler和GTMStackTrace
異常處理程序可以是這樣的:
void uncaughtExceptionHandler(NSException *exception)
{
@try
{
NSString *fullBacktrace = GTMSBStackTraceFromException(exception);
NSMutableString *backtrace = [NSMutableString stringWithUTF8String:""];
NSArray *backtraceArray = [fullBacktrace componentsSeparatedByString:@"\n"];
for (id entry in backtraceArray)
{
NSRange testRange = [entry rangeOfString:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]];
if (testRange.length)
{
[backtrace appendString:entry];
}
}
NSCharacterSet *whitespaces = [NSCharacterSet whitespaceCharacterSet];
NSPredicate *noEmptyStrings = [NSPredicate predicateWithFormat:@"SELF != ''"];
NSArray *parts = [backtrace componentsSeparatedByCharactersInSet:whitespaces];
NSArray *filteredArray = [parts filteredArrayUsingPredicate:noEmptyStrings];
NSString *strippedBacktrace = [filteredArray componentsJoinedByString:@" "];
[FlurryAnalytics logError:@"uncaughtExceptionHandler"
message:[NSString stringWithFormat:@"%@", strippedBacktrace ? strippedBacktrace : @"no matching backtrace"]
exception:exception];
}
@catch (NSException *exception)
{
NSLog(@"whoa! could not handle uncaught exception!");
[FlurryAnalytics logError:@"uncaughtExceptionHandler"
message:@"no matching backtrace"
exception:exception];
}
}
Testflight也有一個很好的崩潰日誌。
這是進行測試,或者公開發布? – 2012-08-16 14:58:28
@glennsayers這將是應用程序的公開發布 – GeekedOut 2012-08-16 15:00:07
我知道你正在尋找一個實時的崩潰報告系統,但蘋果公司確實記錄和彙總了應用程序中的崩潰報告,並且你可以在iTunes中訪問它們隨時連線。 – 2012-08-16 17:56:37