崩溃后 Xcode 总是在 main.m 处停止

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8321184/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 22:36:44  来源:igfitidea点击:

Xcode always stopping at main.m after a crash

iphoneiosxcodeipad

提问by DuckDucking

In the past, with the old and good Xcode 3, every time I had a crash, Xcode stopped at the offending line showing the crash. It was good times, nice to debug.

过去,在旧的和好的Xcode 3中,每次我发生崩溃时,Xcode都会停在显示崩溃的违规行处。这是美好的时光,很高兴调试。

Now with Xcode 4.2, every time the app crashes, it stops at main.m at this line

现在使用 Xcode 4.2,每次应用程序崩溃时,它都会在此行的 main.m 处停止

int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");

that gives no clue to what is causing the crash. The problem can be in any class but it will always stop on main.m when it crashes.

这不知道是什么导致了崩溃。问题可能出现在任何类中,但它在崩溃时总是会在 main.m 上停止。

is there a way to make it work correctly again?

有没有办法让它再次正常工作?

thanks

谢谢

note: I have asked this before on SO, but the solution given that time was proved to be not satisfactory and the problem persists.

注意:我之前在 SO 上问过这个问题,但是鉴于时间证明解决方案并不令人满意并且问题仍然存在。

回答by BarrettJ

They changed the behavior, follow this tutorial to break on all exceptions

他们改变了行为,按照本教程打破所有异常

EDIT:(Link might rot, so I will duplicate the info here)

编辑:(链接可能会腐烂,所以我会在这里复制信息)

One of the hidden gems in Xcode 4.2 is the “Exception Breakpoint” feature. Once you enable it, your debugging life becomes much easier because whenever an exception is thrown in your app, Xcode will bring up the line of code that caused the exception to occur. This is particularly useful if your call stack window is empty (which I have seen happen sometimes while working on iOS apps). Instead of relying on a brief error message in the Output pane, which doesn't contain much more than the type of exception and its error message, you get to see exactly where the problem is!

Xcode 4.2 中隐藏的宝石之一是“异常断点”功能。一旦启用它,您的调试工作就会变得更加轻松,因为每当您的应用程序中抛出异常时,Xcode 都会显示导致异常发生的代码行。如果您的调用堆栈窗口是空的(我在 iOS 应用程序上工作时有时会发生这种情况),这尤其有用。您无需依赖“输出”窗格中的简短错误消息,其中只包含异常类型及其错误消息,您可以准确地看到问题出在哪里!

You can add an Exception Breakpoint by opening up the Breakpoint Navigator pane, and clicking on the X button in the bottom left corner:

您可以通过打开 Breakpoint Navigator 窗格并单击左下角的 X 按钮来添加异常断点:

After clicking the “Add Exception Breakpoint…” menu item, you will see this breakpoint configuration view open up:

单击“Add Exception Breakpoint...”菜单项后,您将看到此断点配置视图打开:

Click the Done button and you will the new Exception Breakpoint in your list of breakpoints. If you want to have all of your Xcode workspaces include the Exception Breakpoint, right-click (Ctrl + click) on it and open the “Move Breakpoint To” menu item:

单击完成按钮,您将在断点列表中出现新的异常断点。如果您希望所有 Xcode 工作区都包含异常断点,请右键单击(Ctrl + 单击)并打开“Move Breakpoint To”菜单项:

After clicking “User” in the submenu, you will see that the Exception Breakpoint is in the User group of breakpoints. Open up another project and it automatically be included in the list of breakpoints.

单击子菜单中的“用户”后,您将看到异常断点在断点的用户组中。打开另一个项目,它会自动包含在断点列表中。

Happy debugging!

调试愉快!

回答by Krishna Kishore

Just try the below steps which worked for me.

只需尝试以下对我有用的步骤。

  1. Open Preferences, select Behaviors tab.
  2. Select "Run exits unexpectedly" from left column.
  3. Select "Show debugger with current views".
  1. 打开首选项,选择行为选项卡。
  2. 从左栏中选择“运行意外退出”。
  3. 选择“使用当前视图显示调试器”。

Unfortunately this is reverted back to main.m in the editor again :) Now you need to follow below steps

不幸的是,这再次在编辑器中恢复为 main.m :) 现在您需要按照以下步骤操作

  1. Open Preferences, select Behaviors tab.
  2. Just go to "run completes"
  3. There find the "Show" line and click the checkbox
  4. On the same line modify target to go to "Current" in the dropdown menu.
  1. 打开首选项,选择行为选项卡。
  2. 只需转到“运行完成”
  3. 在那里找到“显示”行并单击复选框
  4. 在同一行修改目标以转到下拉菜单中的“当前”。

This should work

这应该工作