iOS崩溃报告获取一

在AppDelegate.m文件中实现函数

void UncaughtExceptionHandler(NSException *exception) {
    /**
     *  获取异常崩溃信息
     */
    NSArray *callStack = [exception callStackSymbols];
    NSString *reason = [exception reason];
    NSString *name = [exception name];
    NSString *content = [NSString stringWithFormat:@"异常错误报告
 exception_name:  %@
 exception_reason:  
%@ 
 exception_callStackSymbols:  
%@ 
version:    %@ 
 userInfo:  %@
 returnAddress: %@
",name,reason,[callStack componentsJoinedByString:@"
"]];
    
    JKSQLiteManager *manager = [JKSQLiteManager sharedSQLManager];
    [manager insertInto:@"err" columns:@"(err_text)" values:[NSString stringWithFormat:@"('%@')",content]];
}

然后在

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 方法中调用

NSSetUncaughtExceptionHandler(&UncaughtExceptionHandler);

就可以获取应用的Crash报告了。

异常错误报告

 exception_name:  NSInvalidArgumentException

 exception_reason:  

*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil 

 exception_callStackSymbols:  

0   CoreFoundation                      0x00bfd494 __exceptionPreprocess + 180

1   libobjc.A.dylib                     0x006b7e02 objc_exception_throw + 50

2   CoreFoundation                      0x00aa3f91 -[__NSArrayM insertObject:atIndex:] + 881

3   CoreFoundation                      0x00aa3bf1 -[__NSArrayM addObject:] + 65

4   JKExceptionHandler                  0x000c9be2 -[ViewController crashBtn:] + 130

5   libobjc.A.dylib                     0x006cc0b5 -[NSObject performSelector:withObject:withObject:] + 84

6   UIKit                               0x00f97e38 -[UIApplication sendAction:to:from:forEvent:] + 118

7   UIKit                               0x00f97db7 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64

8   UIKit                               0x0113bf3b -[UIControl sendAction:to:forEvent:] + 79

9   UIKit                               0x0113c2d4 -[UIControl _sendActionsForEvents:withEvent:] + 433

10  UIKit                               0x0113b2c1 -[UIControl touchesEnded:withEvent:] + 714

11  UIKit                               0x0101852e -[UIWindow _sendTouchesForEvent:] + 1095

12  UIKit                               0x010195cc -[UIWindow sendEvent:] + 1159

13  UIKit                               0x00fbabe8 -[UIApplication sendEvent:] + 266

14  UIKit                               0x0df1c369 -[UIApplicationAccessibility sendEvent:] + 72

15  UIKit                               0x00f8f769 _UIApplicationHandleEventQueue + 7795

16  CoreFoundation                      0x00b0fe5f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15

17  CoreFoundation                      0x00b05aeb __CFRunLoopDoSources0 + 523

18  CoreFoundation                      0x00b04f08 __CFRunLoopRun + 1032

19  CoreFoundation                      0x00b04846 CFRunLoopRunSpecific + 470

20  CoreFoundation                      0x00b0465b CFRunLoopRunInMode + 123

21  GraphicsServices                    0x0425a664 GSEventRunModal + 192

22  GraphicsServices                    0x0425a4a1 GSEventRun + 104

23  UIKit                               0x00f95eb9 UIApplicationMain + 160

24  JKExceptionHandler                  0x000cce7a main + 138

25  libdyld.dylib                       0x025c4a25 start + 1

26  ???                                 0x00000001 0x0 + 1 

version:    v1.0.0 

 userInfo:  (null)

 returnAddress: (0xbfd478 0x6b7e02 0xaa3f91 0xaa3bf1 0xc9be2 0x6cc0b5 0xf97e38 0xf97db7 0x113bf3b 0x113c2d4 0x113b2c1 0x101852e 0x10195cc 0xfbabe8 0xdf1c369 0xf8f769 0xb0fe5f 0xb05aeb 0xb04f08 0xb04846 0xb0465b 0x425a664 0x425a4a1 0xf95eb9 0xcce7a 0x25c4a25 0x1)

原文地址:https://www.cnblogs.com/buakaw/p/5849808.html