Chapter 17. Code Quality and Distribution

In this chapter, we’ll talk about some tools and techniques you can use to ensure that your code is as good as it can be. Specifically, we’ll be talking about how to monitor your app and find ways to improve its performance, how to track down and fix bugs, and how to set up your application to run automatic tests on itself, which will help you make changes to the code without accidentally breaking its features.

After that, we’ll talk about how to use automated tools for ensuring that every piece of the app works every step of the way as you continue to build your project. Finally, we’ll talk about how to deal with the App Store, including code signing requirements and delivering your product to Apple for distribution, as well as how to ensure that only the assets that the user’s device actually needs are downloaded.


Sometimes, your code just doesn’t work the way you want it to: either you have a crash, or you have a more subtle behavioral difference. To track down these problems, you can use Xcode’s built-in debugger. A debugger is a program that can interrupt the execution of an app, gather data from its variables, and help you figure out what the app’s doing.

To use the debugger, you add breakpoints. A breakpoint is a point in the program at which the debugger should stop, allowing the developer (that’s you!) to inspect the program’s current state.

When a program is stopped at a breakpoint, you can step through its execution, ...

Get Learning Swift now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.