Easy Tutorial
❮ Att Ios Ui Imageview Ios Universal Applications ❯

IOS Application Debugging


Introduction

When developing applications, we may make various mistakes that can lead to different errors. Therefore, to fix these errors or defects, we need to debug the application.

Choosing a Debugger

The debuggers in Xcode are GDB and LLDB, with GDB being the default. LLDB is a debugger that is part of the LLVM open-source compiler project. You can change the debugger by editing the active scheme options.

How to Find Coding Errors?

We just need to build our application, and the code will be compiled by the compiler. All messages, errors, and warnings will be displayed along with the reasons for the errors, which we can then correct. You can click Product and then click "Analyze" to identify potential issues in the application.

Setting Breakpoints

Breakpoints help us understand the state of our application objects and help us find many defects, including logical issues. We just need to click the line number where we want to create a breakpoint. We can delete a breakpoint by clicking and dragging it. As shown below:

When we run the application and select playVideo, the application will be paused, allowing us to analyze the state of our application. When the breakpoint is triggered, we will get an output, as shown below:

We can easily determine which thread triggered the breakpoint. At the bottom, we can see objects like self, sender, etc., which hold the corresponding object values. We can expand these objects to see their individual states.

To continue the application, we select the continue button (the leftmost button) in the debug area, as shown below. Other options include step over and step into.

Exception Breakpoints

We also have exception breakpoints that trigger the application to stop at the location where an exception occurs. By selecting the debug navigator and then the "+" button, we can create an exception breakpoint. We will get the following window:

Then, we need to select the "Exception Breakpoint (Add Exception)" breakpoint, which will display the following window:

What's Next?

You can learn more about debugging and other Xcode features in the Xcode 4 User Guide.

❮ Att Ios Ui Imageview Ios Universal Applications ❯