iOS - Application Debugging

Advertisements


Introduction

When we do application we may commit mistakes which can lead to different kinds of errors. So in order to fix these errors or bugs we need to debug the application.

Selecting a Debugger

Xcode has to debuggers namely GDB and LLDB debuggers, and GDB is selected by default. LLDB is a debugger that is part of the LLVM open source compiler project. You can change the debugger by edit active schemes option.

How to find coding mistakes?

We just need to build our application and our code is compiled by compiler and all the messages, errors and warnings with their reason will be displayed and we can correct them. You can click Product and click analyze, you will be given the possible issues in the application.

Set Breakpoints

Break points help us to know the different states of our application objects which help us identifying many flaws including logical issues. We just need to click over the line number to create a breakpoint. We can click and drag it out to remove the break point. An example breakpoint is shown below.

iOS Tutorial

When we run the application and select the playVideo button the application will be paused for us to analyze the states of our application. When breakpoint is triggered we will get an output as shown below.

iOS Tutorial

You can easily identify which thread has triggered the breakpoint. In the bottom you can see objects like self, sender and so on which hold the values of corresponding objects and we can expand some of these objects and see what is the state of each of them.

To continue the application we will select the continue button (left most button) in the debug area shown below. The other options include step in, step out and step over.

iOS Tutorial

Exception breakpoint

We also have exception breakpoint that triggers application to stop in location where the exception occurs. We can create exception breakpoint by selecting the + button after selecting the debug navigator. You will get the following window.

iOS Tutorial

Then we need to select Add Exception Breakpoint which will show the following window.

iOS Tutorial

Next what?

You can know more about debugging and other Xcode features in Xcode 4 user guide .



Advertisements
Advertisements