Xcode 4.2 jumps to main.m every time after stopping simulator

后端 未结 11 1285
感情败类
感情败类 2020-12-04 09:28

This is more of a general annoyance. Every time after stopping the simulator, Xcode jumps to main.m for some reason. On the left nav, it jumps to the Debug Navigator.

<
相关标签:
11条回答
  • 2020-12-04 10:09

    None of these solutions worked for me and I find the behavior too intrusive to put up with.

    I get round it by using the 'Assistant Editor' instead of the editor as my main editing window. You access the Assistant Editor using the tiny little bow tie button at the top right of the single window.

    You can set then it to 'Manual'. Click on the button that is the far left crumb of the breadcrumb trail at the top of the Assistant Editor frame and select Manual from the pop-up menu that appears. The Manual setting allows you to select the file you're editing by clicking on the second to last crumb of the breadcrumb trail and selecting the file from the pop-up that appears.

    I then just minimize the size of the main editor - or use it as a secondary editing window, useful given that you can't split the editors into multiple frames any more. Far from ideal - but that's XCode 4 for you.

    0 讨论(0)
  • 2020-12-04 10:12

    When we start debug from xcode, the debugger sets itself up to monitor signals from OS. When we press stop button in XCode (or hit cmd + R - which first stops existing instance running and then try to start new one, somewhat equalant to we press manually stop first and then run) SIGKILL is sent to the debugger.

    Whenever the cause of interruption is from outside the app (in other words all cases where SIGKILL is sent, like stop button press) , debugger jumps to main, since main is the root of the app and the place where your app meets the OS. Debugger has no way to identify why this SIGKILL is issued (pressing stop button in xcode/ press cmd + R/ delete app from multitasking bar etc), but it treats SIGKILL as outside interrupt, and nothing related with your code. So it jumps to main.

    If the cause of interruption is from inside the app (like app crash/SIGABRT) debugger handles it and jumps to the place of crash, which we normally see.

    I do not consider this as an xcode bug, rather a normal way of handling SIGKILL. But if you want to stay at your code and do not want to jump to main you can do two things

    1. You can do as Gabe suggested. As BBonified said, it is like a band-aide, but I think it should work (personally I never tried that)

    2. Report a bug/request for a feature here. Let me tell you you are not the first one to do so. Already a bug has been reported. See this and this. But I don't have much hope of a positive action from Apple

    And I agree with you, it is sometimes annoying. Especially if you have experienced differently in previous XCode versions. But we can only take what they give here.

    0 讨论(0)
  • 2020-12-04 10:12

    I guess it's fair to call it a bug, Xcode 3 specifically suppressed this useless artefact.

    I've had success (four times and counting) with this one-liner in ~/.gdbinit:

    handle SIGKILL nostop noprint nopass
    

    Taken from this gdb manual:

    http://www.delorie.com/gnu/docs/gdb/gdb_39.html

    Not sure if it applies to lldb as well.

    0 讨论(0)
  • 2020-12-04 10:15

    None of the preference adjustments seem to work for me.

    I have been able to track the offending sequence of events. The SIGKILL error message will occur when you run your app and use multiple threads. For instance, when using UIWebView in my app it will abort to main.m. I verified that when UIWebView is not called, XCode can be stopped without the SIGKILL error message returning the user to main.m

    It looks like there are at least two threads that get started when initializing a UIWebView. However, any threads created by you during the running of your app will cause the SIGKILL to improperly notify XCODE to return to the main.

    You can see this in the GDB that there is a switch just before SIGKILL:

    [Switching to process 24957 thread 0x2103]

    [Switching to process 24957 thread 0x7403]

    [Switching to process 24957 thread 0x207]

    Program ended with exit code: 0

    It is definitely still a bug with XCODE that will hopefully be fixed.

    For now, if you avoid executing code that launches a separate thread, it will not change the view back to main.m For code that does launch additional threads, I would recommend quitting the simulator to return to edit mode in XCODE.

    0 讨论(0)
  • 2020-12-04 10:23

    This might not be much. I was able to avoid this problem 99% of the time by waiting for 2 seconds or so after stopping the app, before relaunching it.

    UPDATE: After upgrading to the latest Xcode, I am prompted to use LLDB instead of GDB. The problem seems to be gone now.

    0 讨论(0)
  • 2020-12-04 10:27

    I tried what David suggested but that didn't work for me, so I tried something similar:

    1. Open Preferences, select Behaviors tab.
    2. Select "Run exits unexpectedly" from left column.
    3. Select "Show debugger with current views".

    I'm using Xcode version 4.2 build 4D199.

    EDIT: That worked for about 15 minutes. Then it reverted to bringing up main.m in the editor again.

    0 讨论(0)
提交回复
热议问题