iOS application debugging


IOS application debugging


Introduction

When we make applications, we may make various mistakes, which may lead to various errors. . Therefore, in order to fix these errors or defects, we need to debug the application.

Choose a debugger

The debuggers in Xcode are GDB and LLDB debuggers, GDB is the default. LLDB is a debugger that is part of the LLVM open source compiler project. You can change debugging and edit activity schedule options.

How to find encoding errors?

We only need to build our application, the code is compiled by the compiler and all messages, errors and warnings will be displayed along with the cause of the error and we can correct them. You can click product and then click "Analyze" to identify problems that may occur in the application.

Set breakpoints

Breakpoints help us understand our application objects and help us find many defects, including different states of logic problems. We just need to click on the line number to create a breakpoint. We can delete a breakpoint by clicking and dragging it. As shown below

debug_Breakpoint

#When we run the application and select playVideo, the button application will be paused and let's analyze the status of our application. When the breakpoint is triggered, we will get an output as shown in the image below

debug_BreakpointStop

can easily determine which thread triggered the breakpoint. At the bottom you can see objects, such as self, sender, etc., which hold the values ​​of the corresponding objects. We can expand some of these objects to see what the status of each of them is.

To continue the application, we select the Continue button (the leftmost button) in the debugging area, as shown in the figure below. Other options include step and step skip

Exception Breakpoints

We also have exception breakpoints, which trigger the application to stop where an exception occurs. By selecting the " " button after selecting the debug navigation, we can create exception breakpoints. You will get the following window

debug_ExceptionBreakpoint

Then, we need to select the "Exception Breakpoint (Add Exception)" breakpoint and it will show the following window

debug_ExceptionBreakpointAll

What’s next?

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