简体   繁体   English

断点未在 Xcode (9.3) 中命中

[英]Breakpoints not hit in Xcode (9.3)

None of my breakpoints are being hit.我的断点都没有被击中。

I've tried the following:我尝试了以下方法:

  • Deleted Derived Data directory删除的派生数据目录
  • Cleaned build folder清理构建文件夹
  • Deleted the xcuserdata directory删除了 xcuserdata 目录
  • Made sure build configuration is Debug and Debug executable is ticked确保构建配置为Debug并勾选了Debug executable
  • Made sure Generate debug symbols is set to Yes确保Generate debug symbols设置为Yes
  • Changed Optimization level to No optimizationOptimization level更改为No optimization

The breakpoints are still not being hit.断点仍然没有被击中。

Had this exact issue today - breakpoints in Swift projects were failing in XCode 9.3 (objective-c ones were fine).今天遇到了这个确切的问题 - Swift 项目中的断点在 XCode 9.3 中失败(objective-c 很好)。

The following fixed it:以下修复了它:

change Optimization level under the Swift Compiler - Code Generation submenu.在 Swift Compiler - Code Generation 子菜单下更改优化级别。 Move it from -O to -Onone将它从 -O 移动到 -Onone

在此处输入图片说明

src: https://www.reddit.com/r/swift/comments/89nht7/breakpoints_not_working_after_updating_to_xcode_93/?st=jftp4n02&sh=49688058源代码: https : //www.reddit.com/r/swift/comments/89nht7/breakpoints_not_working_after_updating_to_xcode_93/? st = jftp4n02 & sh =49688058

Try below steps尝试以下步骤

  1. Go to debug (top bar in Xcode)转到调试(Xcode 中的顶部栏)
  2. Debug Workflow调试工作流
  3. Always show Disassembly - uncheck it始终显示反汇编 - 取消选中它

None of the existing answers worked for me so I dug into what was going on.现有的答案都不适合我,所以我深入研究了发生了什么。 By forcing a breakpoint in code (ie an asm("int3;") instruction) I was able to see that the symbols weren't loading.通过在代码中强制断点(即 asm("int3;") 指令),我能够看到符号没有加载。 Naturally breakpoints depend on symbol information being loaded.自然断点取决于加载的符号信息。

The code for which my breakpoints weren't working was in a C++ framework and the framework has a build setting called " Strip linked product " which was defaulted to "Yes" for both release and debug builds.我的断点不起作用的代码在 C++ 框架中,并且该框架有一个名为“ Strip links product ”的构建设置,对于发布和调试构建,它默认为“Yes”。 By setting this to "No" for the debug build (and doing a full rebuild) my breakpoints now work again.通过将调试版本设置为“否”(并进行完全重建),我的断点现在又可以工作了。

I had set Deployment Postprocessing to NO in my Build Settings for my target.我在目标的构建设置中将Deployment Postprocessing设置为NO Setting this to YES made my breakpoints work again.将此设置为YES使我的断点再次起作用。

In my case problem was in the Debug information format setting.就我而言,问题出在调试信息格式设置中。 It was set to DWARF instead of DWARF with dSYM File .它被设置为DWARF而不是DWARF with dSYM File Reseting it to the default value solved the problem.将其重置为默认值解决了问题。

Check Preferences > Behaviors > Running > Pauses options.检查首选项 > 行为 > 运行 > 暂停选项。 The Show for navigator and debugger must have ticked.导航器和调试器的显示必须已勾选。

I was facing the same issue and this solution works for me:我遇到了同样的问题,这个解决方案对我有用:

  • Open project settings打开项目设置
  • Optimization Level优化级别
  • Under "Swift Complier - Code Generation" Section在“Swift 编译器 - 代码生成”部分下
  • Set " Optimization Level " to No Optimization[-Onone]将“优化级别”设置为无优化[-Onone]

Refer attached screen shot请参阅附加的屏幕截图在此处输入图片说明

在此处输入图片说明

Select breakpoint tab in XCode delete all the old breakpoints.在 XCode 中选择断点选项卡删除所有旧断点。 Then add new breakpoints.然后添加新的断点。 It worked for me.它对我有用。

None of the previous solutions worked for me either.以前的解决方案都不适合我。 I had an issue where all my breakpoints would work except on a c++ project among other projects in an xcode (9.4.1) workspace.我有一个问题,除了 xcode (9.4.1) 工作区中的其他项目中的 c++ 项目外,我的所有断点都可以工作。 For that project, I noticed that only some breakpoints were working.对于那个项目,我注意到只有一些断点有效。 Digging deeper showed that it was breakpoints made within private methods that did not work.深入挖掘表明,在私有方法中创建的断点不起作用。

After a good deal of investigation, I found my particular issue.经过大量调查,我发现了我的特殊问题。 In my main project, I had declared some static objective-c initializers in a header file.在我的主要项目中,我在头文件中声明了一些静态的 Objective-c 初始值设定项。 Not entirely sure why, but after I moved these to the implementation file where they were referenced, my broken breakpoints started working again.不完全确定为什么,但是在我将这些移动到引用它们的实现文件后,我的断点又开始工作了。 Hope this saves someone some time.希望这可以节省一些时间。

Setting Build Active Architecture Only to Yes helps me.Build Active Architecture Only设置为Yes对我帮助。

在此处输入图片说明

  1. Set Deployment Postprocessing to "Yes" in my Build Settings for my target.在我的目标的构建设置中将部署后处理设置为“是”。
  2. Debug -> Debug Workflow -> Always show Disassembly -> Uncheck调试 -> 调试工作流 -> 始终显示反汇编 -> 取消选中
  3. Quit Xcode and reopen the Xcode.退出 Xcode 并重新打开 Xcode。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM