Sunday, November 23, 2014

iOS Tutorial - Part 25 - Xcode - debugging - tools

Xcode debugging tools


Video Description 
Sometimes when you run the app and do some actions, application stops and it goes to a class name "main.m". This is happen when an exception raises that is not handled. In order to get more information about the crash and the exception we have different tools. In the following we will get familiar with some of these tools.

Console:

When exception raises or app crashes, at the bottom of the Xcode, you can see console that has some useful information. It can tells what kind of exception happened and what method causes this problem.

All Exception Breakpoint:

From console we can see the method name that causes the error but it's very inefficient to search all over the code to find the method. In order to find the line of code that causes the crash we need to add "All Exception Breakpoint". Open Breakpoint navigator tab on the top left side of Xcode. At the very bottom of the page click on "+" button. Select "Add Exception Breakpoint". Now if you run the program and it crashes, it brings up the line of code that causes the crash.

Custom Breakpoint

You can add custom breakpoint anywhere in your app. It stops the app and shows the line of code you add the breakpoint. In order to add custom breakpoint, just click on the left side border of the line you want. Blue arrow will show up. If you run the application and it reaches the breakpoint you have multiple buttons that you can use to get more detail information. These buttons are as follow:


Continue:

It will continue running the application (Executing rest of the code).

Step Over:

It will go one step ahead, for example if there is a line after your breakpoint it will go to the next line.

Step into:

It will go deep inside of that line of code. For example if you call other methods in this line if you step into, it will go to that method. If you have property in that line it will show setter and getter. If there is nothing to go in, it will go to the next line.

Step out:

If you step into via the "Step into" button, you can go out by pressing "Step out".

Conditional Breakpoint:

If you add a breakpoint, whenever app reaches that line of code, it will pause and show the line you specified. If you want to pause only in certain condition, just right click on the breakpoint and from the opening menu select "Edit Breakpoint". From the opening window add your condition in the blank field. Your condition should be written in objective c language.

Debug View Hierarchy:

If you want to have a 3D view of your application, run the application then press "Debug View Hierarchy"

No comments:

Post a Comment