Xcode Debugging Skills

There’s no complex app that is completely bug-free. We need to debug not only logic flow but also user interface to make sure our app is okay. By debugging it under different environment or investigate reported issues, we try to make our app’s unwanted behaviour as low as possible.

 

All Exceptions

I usually use this to test work flow and make sure the app logic is working as intended. For example the app is supposed to go into Loop A and stop at condition B rather than condition C, using breakpoint make it a lot easier to do so.

Way 1 : Xcode > Code Left (where you can see your line no.) > Click on it and you will see a blue arrow appear) > Breakpoint at the position you want > Run the simulator and see if it stop at the blue arrow position

*Note: When you clicked “Add Exception Breakpoint”, the app will stop at potential hazard point that is not noticeable by you and you can double check if it will cause crash or any serious issue.

Debug1

Debug View Hierarchy (iOS 8 and above)

This can only work in iOS 8 and above in Xcode. This is very helpful when you have no idea if you elements are not displayed as intended or just being hidden behind. Xcode provides some settings for developer to examine their UIs (see attached photo) to have the better view at the UI sequence breakdown.

Way 1 : Xcode > Run the app on simulator > Click on “Debug Hierarchy Mode”

Debug4

Console terminal

A convenient place where you can println(or NSLog) variables or any bookmarked exception point.

Way 1 : Xcode> Console (bottom) > Breakpoint at the position you want > Get the variable (on the left console) > Right click to show “Print Description of…xxx”

Way 2 : Xcode> Console (bottom) > Breakpoint at the position you want > Go to the right console and click at the libd (last line) to have your input > type “po <variable>” to show your wanted response

*note: you can “po myArray.count” to show count or “po myDog.name” to get the property of an object

 

Debug2
Debug3

 

Safari

That’s right. Safari can play in a part when we are trying to debug styling in our simulator. When the backend gives you html and to present it with styling and scrollable with other features (more buttons or links..etc), one of the ways is to put the html together in webview with styling css. When you need to debug your html/css in simulator, you can open your Safari to get real-time response.

Way 1: Open Safari > Developer > iOS Simulator (Usually is the first one)

You will notice your simulator’s part will be highlighted like Chrome’s inspect element.

debug 6

debug7

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s