为什么 Xcode 断点不起作用?

发布于 2024-07-04 21:23:33 字数 30 浏览 7 评论 0原文

我设置了断点,但 Xcode 似乎忽略了它们。

I have breakpoints set but Xcode appears to ignore them.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(30

岁月染过的梦 2024-07-11 21:23:34

另一件需要检查的事情是,如果您的调试模式有一个“Entitlements”plist 文件(可能是因为您正在使用钥匙串进行操作),请确保该 plist 文件具有“get-task-allow”= YES 行。 没有它,调试和日志记录将会被破坏。

Another thing to check is that if you have an "Entitlements" plist file for your debug mode (possibly because you're doing stuff with the Keychain), make sure that plist file has the "get-task-allow" = YES row. Without it, debugging and logging will be broken.

尛丟丟 2024-07-11 21:23:34

设置断点时,右键单击,您应该会看到几个有关如何处理断点的选项(记录变量并继续、暂停执行等)

还要确保在调试首选项中未选择“延迟加载符号”。

(适用于 Xcode 3.1,不确定过去/未来的版本)

When setting your break point, right click and you should get several options about how the break point is handled (log vars and continue, pause execution, etc)

Also make sure the "Load Symbols lazily" is not selected in the debug preferences.

(Applies to Xcode 3.1, not sure about past/future versions)

城歌 2024-07-11 21:23:34

来到这个页面时遇到了同样的问题(Xcode 6 中的 C 代码没有在断点处停止),上面的解决方案都不起作用(该项目实际上是开箱即用的,设置方面,所以任何调试器设置都没有机会被设置为错误的值)...

在浪费了相当长的时间减少问题之后,我终于找出了罪魁祸首(对于我的代码):

Xcode (/LLVM) 不喜欢 Bison 风格 #line 预处理器命令。

删除它们解决了问题(调试器在我的断点处停止)。

Came to this page with the same problem (C code in Xcode 6 not stopping at breakpoints) and none of the solutions above worked (the project was practically out of the box, settings-wise, so little chance for any of the debugger settings to be set to the wrong value)...

After wasting quite some time reducing the problem, I finally figured out the culprit (for my code):

Xcode (/LLVM) does not like Bison-style #line preprocessor commands.

Removing them fixed the problem (debugger stopped at my breakpoints).

我乃一代侩神 2024-07-11 21:23:34

对于 Xcode 4:

go Product -> Debug ->  Activate Breakpoints

这适用于所有 Xcode 版本。 快捷键为:命令键 + Y。 按此组合键可激活/停用断点。

For Xcode 4:

go Product -> Debug ->  Activate Breakpoints

This is applicable for all Xcode version. Shortcut key is: command key + Y. Press this key combination to activate/deactivate breakpoints.

迟月 2024-07-11 21:23:34

另请确保设备上未安装该应用程序的 AppStore 发行版。

Also make sure that the AppStore distribution of the app is not also installed on the device.

赠我空喜 2024-07-11 21:23:34

您可以在下拉菜单中激活/禁用断点
在此处输入图像描述

You can Activate / Disactivate Breakpoints in dropdown menu
enter image description here

赠佳期 2024-07-11 21:23:34

我尝试了上述所有方法,但对我来说,只需停用一次调试断点,然后激活它们即可。

I tried all the above things but for me only deactivating the debugging breakpoints once and then activating them worked.

青柠芒果 2024-07-11 21:23:34

我遇到了这样的问题,在浪费了很多时间之后,我意识到其他开发人员使用特殊字符创建了一个文件夹,在重命名文件夹断点后又恢复了工作

I was facing a problem like that and after a lot of wasted time i realized that other developer created a folder using special characters, after renamed folder breakpoints is back working

ゝ偶尔ゞ 2024-07-11 21:23:34

2024 年经历了同样的事情,使用 Xcode 15.2,并尝试在 iOS 16.4 上进行调试,该版本仅适用于 iPhone 8 Plus。 切换到iOS 17模拟器,一切正常。

其他修复(例如清理、重新启动、目标方案更改等)都不起作用。

Experiencing the same in 2024, using Xcode 15.2, and trying to debug on iOS 16.4 which is only available till iPhone 8 Plus. Switched to iOS 17 simulator and it is working fine.

None of the other fixes like cleaning, restarting, target scheme changes etc worked.

蛮可爱 2024-07-11 21:23:34

我发现了问题。 不知何故,在我的 XCode 中启用了“调试时显示反汇编”,这导致了该问题。 当我禁用它时,我的所有调试器都停止在我的源代码中。

您可以在调试时在产品->调试工作流程->显示反汇编下找到它。

I found the problem. Somehow the "Show Disassembly when debugging" was enabled in my XCode which creates that problem. When I disabled it, all my debugger stopped in my source code.

You can find it under: Product->Debug Workflow->Show Disassembly when debugging.

辞旧 2024-07-11 21:23:34

在Xcode 4中

- Product menu > Manage Schemes
- Select the scheme thats having debugging problems (if only one choose that)
- Click Edit button at bottom
- Edit Scheme dialog appears
- in left panel click on Run APPNAME.app
- on Right hand panel make sure youre on INFO tab
- look for drop down DEBUGGER:
- someone had set this to None
- set to LLDB if this is your preferred debugger
- can also change BUILD CONFIGURATION drop down to Debug 
-      but I have other targets set to AdHoc which debug fine once Debugger is set

In Xcode 4

- Product menu > Manage Schemes
- Select the scheme thats having debugging problems (if only one choose that)
- Click Edit button at bottom
- Edit Scheme dialog appears
- in left panel click on Run APPNAME.app
- on Right hand panel make sure youre on INFO tab
- look for drop down DEBUGGER:
- someone had set this to None
- set to LLDB if this is your preferred debugger
- can also change BUILD CONFIGURATION drop down to Debug 
-      but I have other targets set to AdHoc which debug fine once Debugger is set
素染倾城色 2024-07-11 21:23:34

在 XCode 6.3.1 中我也发生了同样的事情。
我设法通过以下方式修复它:

  • 转到查看->导航器->显示调试导航器
  • 右键单击项目根->; 移动断点(如果选择了“用户”选项)
  • (我还选择了共享断点选项,尽管我不确定是否有必要)。

完成该更改后,我将“移动断点”选项设置回项目,并取消选择“共享断点”选项,但仍然有效。

我不知道为什么,但这让我的断点恢复了。

It has happened the same thing to me in XCode 6.3.1.
I managed to fix it by:

  • Going to View->Navigators->Show Debug Navigators
  • Right click in the project root -> Move Breakpoints (If selected the User option)
  • (I also Selected the option share breakpoints, even though I'm not sure if that necessary).

After doing that change I set the Move breakpoints options back to the project, and unselecting the Share breakpoints option, and still works.

I don't exactly know why but this get my breakpoints back.

熊抱啵儿 2024-07-11 21:23:34

为此,对于 Xcode 6 及更高版本,请确保断点状态按钮已激活(蓝色箭头状按钮):

在此输入图像描述

For this, and also for Xcode 6 and above make sure that the breakpoint state button is activated (the blue arrow-like button):

enter image description here

一花一树开 2024-07-11 21:23:34

如果所有其他方法都失败,您可以调用以下函数而不是断点:

void BreakPoint(void) {
    int i=1;
    #if !__OPTIMIZE__
    printf("Code is waiting; hit pause to see.\n");
    while(i);
    #endif
}

要恢复,请手动将 i 设置为零,然后单击恢复按钮。

If all else fails, instead of a breakpoint, you can call the following function:

void BreakPoint(void) {
    int i=1;
    #if !__OPTIMIZE__
    printf("Code is waiting; hit pause to see.\n");
    while(i);
    #endif
}

To resume, manually set i to zero, then hit the resume button.

温柔戏命师 2024-07-11 21:23:34

删除我的 Build 文件夹解决了我的问题。

Deleting my Build folder solved the problem for me.

北城挽邺 2024-07-11 21:23:34

我认为问题可能是设备版本和 Xcode 之间不兼容。 我在运行 iOS 5.0.1 的 iPhone 4S 上尝试调试时遇到此问题。 我仍在使用 Xcode 3.2.5。 我通过在管理器窗口中选择“使用此设备进行开发”从手机中获取了符号。 然而这款手机拒绝断点。 我的旧 3GS 断点,相同的 Xcode 项目,相同的设置...只是不同的设备,并且运行的是 iOS 4.0。 我猜这是 3.2.5 中的 Xcode bug,因为我有符号。 到目前为止,在尝试了此处发布的所有解决方案后,我决定解决我的问题的方法是继续升级到 XCode 4。除非您的基础 SDK 至少与要调试的系统一样高,否则您可能无法有效地进行调试。 也许这是显而易见的——有人能证实吗?

编辑:当我确认这是真的时,我会更新。

I think the problem could be incompatibility between device versions and Xcode. I have this problem when attempting to debug on my iPhone 4S running iOS 5.0.1. I am still using Xcode 3.2.5. I got the symbols from the handset by selecting "use this device for development" in the Organiser window. This phone refuses to breakpoint however. My old 3GS will breakpoint, same Xcode project, same settings... just different device and it's running iOS 4.0. I guess this is an Xcode bug in 3.2.5, since I have the symbols. Having tried all the solutions posted here so far, I have decided the solution to my problem is to go ahead and upgrade to XCode 4. Perhaps you cannot debug effectively unless your base SDK is at least as high as the system on which to debug. Maybe that's obvious - can anyone confirm?

Edit: I will update when I can confirm this is true.

花伊自在美 2024-07-11 21:23:34

我的断点不起作用,然后完成“构建/清理所有目标”以使它们再次工作。

I've had my breakpoints not work and then done Build / Clean All Targets to get them working again.

小瓶盖 2024-07-11 21:23:34

我在 Xcode (2.4.1) 中遇到很多断点问题。 我使用的项目仅包含其他项目(例如 Visual Studio 中的解决方案)。 我发现有时断点根本不起作用,除非在起始项目中至少设置了一个断点(即包含我的代码入口点的断点)。 如果唯一的断点位于“较低级别”项目中,它们就会被忽略。

而且,如果您在包含断点所在源代码行的项目中对断点执行操作,Xcode 似乎只能正确处理断点操作。

如果我尝试通过另一个项目删除或禁用断点,该操作有时不会生效,即使调试器指示它已生效。 因此,我会发现自己在禁用的断点上或在我之前删除的(现在不可见的)断点上中断。

I have a lot of problems with breakpoints in Xcode (2.4.1). I use a project that just contains other projects (like a Solution in Visual Studio). I find sometimes that breakpoints don't work at all unless there is at least one breakpoint set in the starting project (i.e. the one containing the entry point for my code). If the only breakpoints are in "lower level" projects, they just get ignored.

It also seems as if Xcode only handles breakpoint operations correctly if you act on the breakpoint when you're in the project that contains the source line the breakpoint's on.

If I try deleting or disabling breakpoints via another project, the action sometimes doesn't take effect, even though the debugger indicates that it has. So I will find myself breaking on disabled breakpoints, or on a (now invisible) breakpoint that I removed earlier.

只是一片海 2024-07-11 21:23:34

我使用 XCode 9.4.1 的解决方案(没有在任何断点处停止):

在构建目标 -> 下 构建设置 -> 优化级别:
从“优化速度”切换-> “没有优化”(现在速度较慢但有效)

Solution for me with XCode 9.4.1 (did not stop at any breakpoint):

Under build Target -> Build Settings -> Optimization Level:
Switched from "Optimize for speed" -> "No optimization" (now it's slower but works)

菊凝晚露 2024-07-11 21:23:34

在我的例子中解决这个问题的方法非常简单,在 Xcode - 产品 - 清理构建文件夹中,然后是产品 - 运行(而不是“播放 Xcode”按钮)。

(在使用 Xcode 播放按钮长按切换到单元测试后,Xcode 11 -beta 4 上出现了问题)

What solved it in my case was quite simple, in Xcode - Product - Clean Build Folder followed by Product - Run (not the Play Xcode button).

(Had the issue on Xcode 11 -beta 4 after switching to unit testing with Xcode play button long press)

蓝梦月影 2024-07-11 21:23:34

请参阅这篇文章:断点在 Xcode 中不起作用?。 您可能会按“运行”而不是“调试”,在这种情况下您的程序不会在 gdb 的帮助下运行,在这种情况下您不能指望断点起作用!

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!

那些过往 2024-07-11 21:23:34

这让我在 Xcode 9 中度过了半令人沮丧的一天。 它最终是一个简单的调试设置。

去调试> 调试工作流程并确保“始终显示反汇编”已关闭。 就那么简单。 :(

This had me in Xcode 9 for half a frustrating day. It ended up been a simple debug setting.

Go Debug > Debug Workflow and make sure 'Always Show Disassembly' is turned off. Simple as that. :(

诗酒趁年少 2024-07-11 21:23:34

另一个原因

在 BuildSettings 中将 DeploymentPostprocessing 设置为 NO - 详细信息在此

简而言之 -

激活此设置表示应删除二进制文件并
文件模式、所有者和组信息应设置为标准
价值观。 [DEPLOYMENT_POSTPROCESSING]

在此输入图像描述

Another reason

Set DeploymentPostprocessing to NO in BuildSettings - details here

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]

enter image description here

辞取 2024-07-11 21:23:33

可能的解决方案之一可能是...转到“产品”>“方案”>“编辑方案”>..在“运行”>“信息”>“可执行文件”下
检查“调试可执行文件”。

One of the possible solutions for this could be ....go to Product>Scheme>Edit scheme>..Under Run>info>Executable
check "Debug executable".

段念尘 2024-07-11 21:23:33

对于 Xcode 4.x:
转到“产品”>“调试工作流程”并取消选中“调试时显示反汇编”。

对于 Xcode 5.x
转到“调试”>“调试工作流程”并取消选中“调试时显示反汇编”。

For Xcode 4.x:
Goto Product>Debug Workflow and uncheck "Show Disassembly When Debugging".

For Xcode 5.x
Goto Debug>Debug Workflow and uncheck "Show Disassembly When Debugging".

忆梦 2024-07-11 21:23:33

我刚刚(再次)遇到了同样的问题。 在三次检查“惰性加载符号”并剥离和调试信息生成标志后,我执行了以下操作:

  1. 退出 Xcode
  2. 打开终端窗口并 cd 到项目目录
  3. cd 到 .xcodeproj 目录
  4. 删除除 .pbxproj 文件之外的所有内容(我有Frank.mode1v3 和 Frank.pbxuser)

您可以在 Finder 中通过右键/选项单击 .xcodeproj 包并选择“显示包内容”来完成相同的任务。

当我重新启动 Xcode 时,我的所有窗口都已重置为默认位置等,但断点有效!

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:

  1. quit Xcode
  2. open a terminal window and cd to the project directory
  3. cd into the .xcodeproj directory
  4. delete everything except the .pbxproj file (I had frank.mode1v3 and frank.pbxuser)

You can accomplish the same task in finder by right/option-clicking on the .xcodeproj bundle and picking "Show Package Contents".

When I restarted Xcode, all of my windows had reset to default positions, etc, but breakpoints worked!

空‖城人不在 2024-07-11 21:23:33

在 Xcode 7 中,对我有用的是:

  1. 确保 Target > > 方案> 运行 - 处于调试模式(之前为发布)

  2. 确保选中“调试可执行文件”选项:

调试可执行文件

In Xcode 7, what worked for me was:

  1. Make sure that the Target > Scheme > Run - is in Debug mode (was Release)

  2. Make sure to check the option "Debug executable":

Debug executable

咋地 2024-07-11 21:23:33

转到 Xcode 调试首选项。
确保未选择“延迟加载符号”。

Go to the Xcode Debugging preferences.
Make sure that "Load Symbols lazily" is NOT selected.

泛滥成性 2024-07-11 21:23:33

问题

  • 背景
    • Xcode13.0
      • 代码:Objective-C
  • 问题:添加了断点,但不起作用
    • 已添加断点但不起作用

(可能)原因及解决方案

  • 原因:Xcode bug
    • 解决方案Product ->清理构建文件夹,然后重试调试(多次)
      • 清理构建文件夹
  • 原因:禁用调试
    • 解决方案:启用它:产品->方案->编辑方案-><代码>运行->信息
      • 构建配置设置为调试
      • 选择/选择/启用:调试可执行文件
      • 选择调试可执行文件
  • 原因:禁用所有断点
    • 解决方案:启用它:调试面板 -> 单击断点图标
      • 单击断点图标
  • 原因:调试信息需要优化
    • 解决方案:不优化
    • 点击项目-> 构建设置 -> Apple Clang - 代码生成 -> 优化级别 -> 调试确保为None[-O0]
      • 调试无 O0
  • 原因:(函数/符号名称)拼写错误
    • 解决方案:更改为正确的(函数/符号)名称
    • 例如:
      • typo=错误(ObjC 函数)名称:-[__NSCFConstantString stringByAppendingString:]:
      • 正确的(ObjC 函数)名称:-[NSString stringByAppendingString:]
  • 原因< /strong>: 恢复符号
    • 解决方案恢复符号
    • 例如:
      • 之前
        • 对于iOS逆向,origin(发布的ipa)Mach-O文件,通常是:stripped = no symbol -> 按函数/符号名称添加断点:不起作用=添加断点将失败
          • xcode br 失败
      • 之后:恢复符号
        • 恢复 iOS 应用程序 (Mach-O) 文件的符号后,(ObjC 函数名称)断点起作用
          • xcode br work

Issue

  • Background
    • Xcode: 13.0
      • code: Objective-C
  • Issue: added breakpoint, but not work
    • added breakpoint but not work

(possible) Reason and Solution

  • Reason: Xcode bug
    • Solution: Product ->Clean Build Folder, then retry debug (multiple time)
      • Clean Build Folder
  • Reason: disabled Debug
    • Solution: enable it: Product->Scheme->Edit Scheme->Run->Info
      • Build Configuration set to Debug
      • choose/select/enable: Debug executable
      • select Debug executable
  • Reason: disabled all breakpoint
    • Solution: enable it: Debug panel -> click breakpoint icon
      • click breakpoint icon
  • Reason: debug info be optimized
    • Solution: not optimize
    • click Project -> Build Settings -> Apple Clang - Code Generation -> Optimization Level -> Debug make sure is None[-O0]
      • Debug None O0
  • Reason: (function/ symbol name) typo
    • Solution: change to correct (function/symbol) name
    • eg:
      • typo=wrong (ObjC function) name: -[__NSCFConstantString stringByAppendingString:]:
      • correct (ObjC function) name: -[NSString stringByAppendingString:]
  • Reason: NOT restore symbol
    • Solution: do restore symbol
    • eg:
      • before
        • for iOS reversing, origin (released ipa ) Mach-O file, typically is: stripped = no symbol -> add breakpont by function/symbol name: Not work = add breakpoint will fail
          • xcode br fail
      • after: restored symbol
        • after restore symbol for iOS app (Mach-O) file, then (ObjC function name) breakpoint worked
          • xcode br work
花伊自在美 2024-07-11 21:23:33

首先,我 100% 同意早期人们所说的关闭关闭延迟加载符号

我还有两件事要补充。

(我的第一个建议听起来很明显,但是第一次有人向我建议时,我的反应是这样的:“拜托,你真的认为我不会更好......哦。”)

  1. < p>确保您没有意外地将“活动构建配置”设置为“发布”。

  2. 在项目的图形树显示中的“目标”下,右键单击目标并执行“获取信息”。 查找名为“生成调试符号”(或类似属性)的属性,并确保其已选中(也称为“打开”)。 另外,您可以尝试查找(也在“目标”>>“获取信息”中)名为“调试信息格式”的属性,并将其设置为“带有 dsym 文件的 Dwarf”。

Target >> 下还有许多其他属性。 获取可能影响您的信息。 寻找诸如优化或压缩代码之类的东西,然后将其关闭(我假设您正在调试模式下工作,所以这是一个不错的建议)。 另外,寻找诸如剥离符号之类的东西,并确保它也处于关闭状态。 例如,对于调试目标,“Strip Linked Product”应设置为“No”。

First of all, I agree 100% with the earlier folks that said turn OFF 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.")

  1. Make sure you haven't accidentally set "Active Build Configuration" to "Release."

  2. 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."

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文