How to Debug in Xcode

Finsi Ennes
7 min readJun 29, 2023

Knowing how to debug is an essential skill for a developer. Not only to identify and solve bugs but to check and optimize your app performance.

In this article, we will see what debugging tools Xcode provides and learn how to use them properly.

Why I should use the debugger?

Developers commonly add print or NSLog statements for debugging. This technique could work but this is not the correct way of fixing bugs.

Why? It adds junk code after the development, leaving your app with a noisy console that makes diagnosing subsequent bugs more difficult.

Instead, you must know how to use the Xcode Debugger.

With this tool we can diagnose an error, reproduce it and then narrow down its root cause by inspecting variables at key points in your code while the app is running with breakpoints.

Steps to solve a bug

Follow these steps to narrow down the cause of a bug and to reproduce it:

  1. Determine where you think the bug happens.
  2. Use a breakpoint to pause your app at before of that point.
  3. Inspect variables and confirm that they have the values you expect.
  4. Step through the code, watch variables and check where…

--

--

Finsi Ennes

iOS Developer. Passionate about coding and UX design. For more content, you can follow me on Instagram @finsi.code