How to catch a Swift crash and do some logging

后端 未结 4 1945
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-16 13:48

In Objective-C, the NSSetUncaughtExceptionHandler can register some functionality to do some last minute logging about the exception.

This doesn\'t catc

4条回答
  •  无人及你
    2020-12-16 14:12

    NSSetUncaughtExceptionHandler(&HandleException);
    signal(SIGABRT, SignalHandler);
    signal(SIGILL, SignalHandler);
    signal(SIGSEGV, SignalHandler);
    signal(SIGFPE, SignalHandler);
    signal(SIGBUS, SignalHandler);
    signal(SIGPIPE, SignalHandler);
    

    This will works for most situations. But I'm also trying to find some way to catch all crashes. Well, if you comd+click to those signals to see documents, you will find there are more than 20 kinds of signals, what I've done is signal(,) all most all kinds of signals. That seems works, but maybe still some crash cannot collect.

提交回复
热议问题