5

我希望每次应用程序崩溃时都显示类和方法名称的回溯。我设法在调试模式下使用此代码(该printTrace函数仅在文件上打印字符串。):

void HandleException(NSException *exception)
{
    [SILogManager printTrace:[NSString stringWithFormat:@"******************** CRASH *********************"]];
    [SILogManager printTrace:[NSString stringWithFormat:@"-> Stack Trace: %@", [exception callStackSymbols]]];
}

虽然这在应用程序发布时不起作用,因为它会产生一个像这样的堆栈跟踪:

******************** 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
)

而且我觉得它不是很有用。我也已经尝试过手动调用backtracebacktrace_symbols但它不起作用!

在项目属性中,我有以下设置,应该在构建时复制所有动态符号,所以我仍然无法弄清楚为什么它不起作用!

构建选项 部署选项

我该怎么做才能在已发布的应用程序中也拥有此功能?我究竟做错了什么?先感谢您!

4

0 回答 0