Search code examples
xcodebreakpoints

Setting a breakpoint in Xcode causes cursor to go to random line


Whenever i set a breakpoint in Xcode, using the gutter, my cursor jumps to a random line of code, typically, 10-20 lines above the breakpoint. Why is it doing this? It is very annoying... Thanks.


Solution

  • This typically happens when you turn on various optimizations in your debug build. Debug builds should have no optimization. I have a list of possible causes here. They reduce to making sure:

    • "Strip Debug Symbols During Copy" is unchecked.

    • "Generate Debug Symbols" is checked.

    • "Optimization Level" is set to "None [-O0]".

    • "Use Separate Strip" is unchecked.

    • "Additional Strip Flags" has nothing set (I don’t think this matters if strip isn't run).

    • "Unroll Loops" is unchecked

    • None of the individual files have optimization-related (like -funroll_loops) flags attached.

    More detail is provided in my post.