I wanted to have a backtrace with the classes and method names displayed every time the app crashes. I managed to do it in debug mode, using this code (the printTrace
function just prints the string on a file.):
void HandleException(NSException *exception)
{
[SILogManager printTrace:[NSString stringWithFormat:@"******************** CRASH *********************"]];
[SILogManager printTrace:[NSString stringWithFormat:@"-> Stack Trace: %@", [exception callStackSymbols]]];
}
Although this won't work when the app is released, because it will produce a stacktrace like this one:
******************** CRASH *********************
-> Stack Trace: (
0 CoreFoundation 0x27b5f60f <redacted> + 150
1 libobjc.A.dylib 0x35613c77 objc_exception_throw + 38
2 CoreFoundation 0x27a733a7 <redacted> + 178
3 iSelz POS 0x000bf6c7 iSelz POS + 403143
4 iSelz POS 0x000bf099 iSelz POS + 401561
5 iSelz POS 0x000dda31 iSelz POS + 526897
6 CFNetwork 0x276b7eed <redacted> + 56
7 CFNetwork 0x276b7ea7 <redacted> + 182
8 CFNetwork 0x276b7f99 <redacted> + 36
9 CFNetwork 0x275cceef <redacted> + 78
10 CFNetwork 0x2766976d <redacted> + 60
11 CFNetwork 0x275bdd71 <redacted> + 60
12 CoreFoundation 0x27a705a1 CFArrayApplyFunction + 36
13 CFNetwork 0x275bdc2b <redacted> + 182
14 CFNetwork 0x275bdaf1 <redacted> + 216
15 CFNetwork 0x275bd98d <redacted> + 48
16 CoreFoundation 0x27b25fd7 <redacted> + 14
17 CoreFoundation 0x27b253eb <redacted> + 222
18 CoreFoundation 0x27b23a69 <redacted> + 768
19 CoreFoundation 0x27a70b31 CFRunLoopRunSpecific + 476
20 CoreFoundation 0x27a70943 CFRunLoopRunInMode + 106
21 GraphicsServices 0x2edf8051 GSEventRunModal + 136
22 UIKit 0x2b0666f1 UIApplicationMain + 1440
23 iSelz POS 0x00066aab iSelz POS + 39595
24 libdyld.dylib 0x35bafaaf <redacted> + 2
)
And I don't find it very useful.
I've also already tried to call backtrace
and backtrace_symbols
manually, but it doesn't work!
In the project properties, I have the following settings, that should copy all the dynamic symbols when building, so I still can't figure out why it isn't working!
What can I do to have this feature also in the released app? What am I doing wrong? Thank you in advance!