Chapter 15. Performance and Debugging

At some point during its development, every game will have performance issues, and every game will crash. Fortunately, iOS has some of the best tools around for squeezing as much performance as possible out of your games and finding bugs and other issues.

In this chapter, you’ll learn about how to use these tools, how to fix problems, and how to get information about how your game’s behaving.

Improving Your Frame Rate

Problem

You need to coax a better frame rate out of your game so that it plays smoothly.

Solution

To improve your frame rate, you first need to determine where the majority of the work is being done. In Xcode:

  1. From the Scheme menu, select your device, so that the application will be installed to the device when you build.
  2. Open the Product menu and choose Profile (or press Command-I).

    The application will build and install onto the device, and Instruments will open and show the template picker (see Figure 15-1).

  3. Select the Time Profiler instrument and run your game for a while. You’ll start seeing information about how much CPU time your game is taking up.
  4. Turn on Invert Call Tree, Hide Missing Symbols, and Hide System Libraries, and turn off everything else in the list, as shown in Figure 15-2.
  5. Take note of the name of the functions that are at the top of the list:

    1. If the top functions are the method in which you call OpenGL, the game is spending most of its time rendering graphics. To improve your frame rate, reduce the number of ...

Get iOS Swift Game Development Cookbook, 2nd Edition 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.