how to debug EXC_CRASH (SIGTRAP)

前端 未结 3 775
日久生厌
日久生厌 2021-02-06 08:06

i\'m running my app are running fine until i resume from background or with out location services, the app will crash.

the crash log shows Exception Type: EXC_CRASH (SI

相关标签:
3条回答
  • 2021-02-06 08:17

    With Xcode 4.2 and iOS 5 uncaught exceptions do not seem to show in the console anymore. I would recommend adding the following or modifying your existing uncaught exception handler to dump the exceptions callstack for you.

    #ifdef DEBUG
    void eHandler(NSException *);
    
    void eHandler(NSException *exception) {
        NSLog(@"%@", exception);
        NSLog(@"%@", [exception callStackSymbols]);
    }
    #endif
    
    int main(int argc, char *argv[]) {
    
    #ifdef DEBUG
        NSSetUncaughtExceptionHandler(&eHandler);
    #endif
    
    ...rest of your main function here...
    
    }
    
    0 讨论(0)
  • 2021-02-06 08:18

    You can also turn on Exception breakpoints. In XCode 4 click your project and choose the breakpoints tab. At the bottom of that tab is | + | - | search bar. Choose the + item and "Add Exeception Breakpoint". You can leave it at All or choose Objective-C. This way you will break in the debugger and be able to see what caused the exeception.

    0 讨论(0)
  • 2021-02-06 08:30

    The easiest way for this kind of crashes which are occuring during development is to add exception break points. You can add exception breakpoint like below

    1. Select the break points option in left menu in XCode

    1. Add the exception break point

    1. Add breakpoint for all the exceptions

    1. Run the app. In most of the cases when exception occurs XCode will stop the execution and show you the line which caused the exception.
    0 讨论(0)
提交回复
热议问题