Chapter 15. Debugging and testing

 

This chapter covers

  • Debugging using different techniques, tools, gauges, and instruments in Xcode
  • Testing your app
  • Testing your app interface

All’s well and good reading a book or following a tutorial, but in the real world things go wrong. And often! This is your chance to put your detective hat on and investigate.

In this chapter, we’ll look at what to do when things go wrong by using debugging. We’ll also look at how to prevent things from going wrong with testing.

Along the way, we’ll explore additional concepts:

  • The console
  • Variables view
  • Breakpoints and the breakpoint navigator
  • The debug navigator and gauges
  • Instruments
  • Unit tests and UI tests

15.1. The setup

A friend has kindly offered to look at your app and see if they can find any bugs. You sent them a link to the GitHub repo for your Xcode project, and a few days later you got this email in return:

Hey—I’ve had a look at the app for you. It’s looking good, but I also found a few odd problems:

  • The book edit form was working well to begin with, but then it started crashing. Don’t know what that’s about.
  • The Cancel button in the book edit form crashes the app.
  • After you add an image and save it, the next time you edit the book and save it, the book cover seems to disappear ... strange?

Oh, I also made a couple of little improvements here and there. Hope that’s okay!

15.2. Debugging mode

15.3. Debugging crash logs in the console

15.4. Examining variables and breakpoints

15.5. Debugging playback with gauges and instruments

15.6. Debugging the user interface

15.7. Testing your app

15.8. Summary