このコードをUncaughtExceptionHandler
アプリの として使用して、クラッシュ情報を取得し、それを返しました。
NSArray *callStack = [exception callStackReturnAddresses];
int i,len = [callStack count];
// void **frames = new void *[len];
void **frames = (void**)malloc(len);
for (i = 0; i < len; ++i) {
frames[i] = (void *)[[callStack objectAtIndex:i] unsignedIntegerValue];
}
char **symbols = backtrace_symbols(frames,len);
/*
* Now format into a message for sending to the user
*/
NSMutableString *buffer = [[NSMutableString alloc] initWithCapacity:4096];
NSBundle *bundle = [NSBundle mainBundle];
[buffer appendFormat:@"Version %@\n\n",[bundle objectForInfoDictionaryKey:@"CFBundleVersion"]];
[buffer appendFormat:@"Device: %@. OS: %@\n", [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion]];
[buffer appendString:@"Uncaught Exception\n"];
[buffer appendFormat:@"Exception Name: %@\n",[exception name]];
[buffer appendFormat:@"Exception Reason: %@\n",[exception reason]];
[buffer appendString:@"Stack trace:\n\n"];
for (i = 0; i < len; ++i) {
[buffer appendFormat:@"%4d - %s\n",i,symbols[i]];
}
今日、iTunes Connect から得られるものと比較してごくわずかなクラッシュ レポートを受け取りました。次のようになります。
0 - 0 CoreFoundation 0x395472a3 + 162
1 - 1 libobjc.A.dylib 0x3343697f objc_exception_throw + 30
2 - 2 CoreFoundation 0x395471c5 + 0
3 - 3 Foundation 0x342ec7cb + 66
4 - 4 myapp 0x0012887d myapp + 424061
5 - 5 myapp 0x001285ed myapp + 423405
6 - 6 myapp 0x0013f1f1 myapp + 516593
7 - 7 libdispatch.dylib 0x3783a11f + 10
8 - 8 libdispatch.dylib 0x378394b7 + 22
9 - 9 libdispatch.dylib 0x3783e1bd + 224
10 - 10 CoreFoundation 0x3951af3b + 1290
11 - 11 CoreFoundation 0x3948debd CFRunLoopRunSpecific + 356
12 - 12 CoreFoundation 0x3948dd49 CFRunLoopRunInMode + 104
13 - 13 GraphicsServices 0x3785b2eb GSEventRunModal + 74
14 - 14 UIKit 0x326cd2f9 UIApplicationMain + 1120
15 - 15 myapp 0x000e72e7 myapp + 156391
16 - 16 myapp 0x000c2530 myapp + 5424
レポートでメモリアドレスを記号化するためにatosを使用しましたが、3つのアドレス0x0013f1f1
0x001285ed
0x0012887d
が返さ__PRETTY_FUNCTION__.20480 (in myapp) + 101235
__PRETTY_FUNCTION__.20480 (in myapp) + 8047
__PRETTY_FUNCTION__.20480 (in myapp) + 8703
れるだけで、あまり役に立ちません。少なくともクラッシュの原因となったメソッド名を見つけるために他にできることはありますか?
そうでない場合UncaughtExceptionHandler
、メソッド名を取得するために追加できるもの、または将来のリリースで実行できるものはありますか? iTunes Connect のクラッシュ レポートが表示されないため、このルートを選択しました。
ありがとう