xcode 为什么我的断点不起作用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/64790/
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
Why aren't my breakpoints working?
提问by AlanKley
I have breakpoints set but Xcode appears to ignore them.
我设置了断点,但 Xcode 似乎忽略了它们。
回答by pestophagous
First of all, I agree 100% with the earlier folks that said turn OFFLoad Symbols Lazily
.
首先,我 100% 同意较早的人所说的关闭Load Symbols Lazily
。
I have two more things to add.
我还有两件事要补充。
(My first suggestion sounds obvious, but the first time someone suggested it to me, my reaction went along these lines: "come on, please, you really think I wouldn't know better...... oh.")
(我的第一个建议听起来很明显,但第一次有人向我建议时,我的反应是这样的:“拜托,你真的认为我不会知道更好......哦。”)
Make sure you haven't accidentally set "Active Build Configuration" to "Release."
Under "Targets" in the graphical tree display of your project, right click on your Target and do "Get Info." Look for a property named "Generate Debug Symbols" (or similar) and make sure this is CHECKED (aka ON). Also, you might try finding (also in Target >> Get Info) a property called "Debug Information Format" and setting it to "Dwarf with dsym file."
确保您没有意外地将“Active Build Configuration”设置为“Release”。
在项目的图形树显示中的“目标”下,右键单击您的目标并执行“获取信息”。查找名为“Generate Debug Symbols”(或类似的)的属性,并确保它是 CHECKED(又名 ON)。此外,您可以尝试查找(也在 Target >> Get Info 中)一个名为“Debug Information Format”的属性并将其设置为“Dwarf with dsym file”。
There are a number of other properties under Target >> Get Info that might affect you. Look for things like optimizing or compressing code and turn that stuff OFF (I assume you are working in a debug mode, so that this is not bad advice). Also, look for things like stripping symbols and make sure that is also OFF. For example, "Strip Linked Product" should be set to "No" for the Debug target.
Target >> Get Info 下还有许多其他属性可能会影响您。寻找优化或压缩代码之类的东西并将其关闭(我假设您正在调试模式下工作,因此这不是一个坏建议)。此外,寻找诸如剥离符号之类的东西,并确保它也处于关闭状态。例如,对于调试目标,“Strip Linked Product”应设置为“No”。
回答by Oded Regev
回答by AlanKley
Go to the Xcode Debugging preferences. Make sure that "Load Symbols lazily" is NOT selected.
转到 Xcode 调试首选项。确保未选择“延迟加载符号”。
回答by Frank Szczerba
I was just having this same issue (again). After triple-checking "Load symbols lazily" and stripping and debug info generation flags, I did the following:
我只是遇到了同样的问题(再次)。在三重检查“延迟加载符号”并剥离和调试信息生成标志后,我执行了以下操作:
- quit Xcode
- open a terminal window and cd to the project directory
- cd into the .xcodeproj directory
- delete everything except the .pbxproj file (I had frank.mode1v3 and frank.pbxuser)
- 退出Xcode
- 打开终端窗口并cd到项目目录
- cd 进入 .xcodeproj 目录
- 删除除 .pbxproj 文件之外的所有内容(我有 frank.mode1v3 和 frank.pbxuser)
You can accomplish the same task in finder by right/option-clicking on the .xcodeproj bundle and picking "Show Package Contents".
您可以通过右键/选项单击 .xcodeproj 包并选择“显示包内容”在 finder 中完成相同的任务。
When I restarted Xcode, all of my windows had reset to default positions, etc, but breakpoints worked!
当我重新启动 Xcode 时,我的所有窗口都已重置为默认位置等,但断点有效!
回答by bneupaane
For Xcode 4.x: Goto Product>Debug Workflow and uncheck "Show Disassembly When Debugging".
对于 Xcode 4.x:转到产品>调试工作流并取消选中“调试时显示反汇编”。
For Xcode 5.x Goto Debug>Debug Workflow and uncheck "Show Disassembly When Debugging".
对于 Xcode 5.x 转到调试>调试工作流程并取消选中“调试时显示反汇编”。
回答by gbk
Another reason
另一个原因
Set DeploymentPostprocessing
to NO in BuildSettings - details here
DeploymentPostprocessing
在 BuildSettings 中设置为 NO -详情请点击此处
In short -
简而言之 -
Activating this setting indicates that binaries should be stripped and file mode, owner, and group information should be set to standard values. [DEPLOYMENT_POSTPROCESSING]
激活此设置表示应剥离二进制文件,并将文件模式、所有者和组信息设置为标准值。[DEPLOYMENT_POSTPROCESSING]
回答by Soong
See this post: Breakpoints not working in Xcode?. You might be pushing "Run" instead of "Debug" in which case your program is not running with the help of gdb, in which case you cannot expect breakpoints to work!
请参阅这篇文章:断点在 Xcode 中不起作用?. 您可能正在推动“运行”而不是“调试”,在这种情况下,您的程序没有在 gdb 的帮助下运行,在这种情况下,您不能指望断点起作用!
回答by Strinder
Solution for me with XCode 9.4.1 (did not stop at any breakpoint):
使用 XCode 9.4.1 为我提供的解决方案(没有在任何断点处停止):
Under build Target -> Build Settings -> Optimization Level: Switched from "Optimize for speed" -> "No optimization" (now it's slower but works)
在构建目标 -> 构建设置 -> 优化级别:从“优化速度”->“无优化”切换(现在速度较慢但有效)
回答by Lukas
What solved it in my case was quite simple, in Xcode - Product - Clean Build Folder followed by Product - Run (not the Play Xcode button).
在我的情况下解决它的方法非常简单,在 Xcode - Product - Clean Build Folder 中,然后是 Product - Run(不是 Play Xcode 按钮)。
(Had the issue on Xcode 11 -beta 4 after switching to unit testing with Xcode play button long press)
(在使用 Xcode 播放按钮长按切换到单元测试后,Xcode 11 -beta 4 出现问题)
回答by Soropromo
One of the possible solutions for this could be ....go to Product>Scheme>Edit scheme>..Under Run>info>Executable check "Debug executable".
可能的解决方案之一可能是....转到产品>方案>编辑方案>..在运行>信息>可执行文件中检查“调试可执行文件”。