Tips to improve your Xcode workflow

Gabriel Lewis
Aug 20, 2018 · 4 min read

Xcode is an amazing tool to create iOS apps, but sometimes it can be a little clunky and slow down your workflow. Here are a couple of tips to improve your workflow, hopefully saving you time and headaches.

1. Track Build times

Build times are the worst thing about Xcode. To improve anything you first need some way of measuring it. To measure build times in Xcode in seconds open terminal and type this command:

defaults write ShowBuildOperationDuration -bool YES

Afterwards you might need to restart Xcode to see the change. You should see build times appear in the top tool bar after each build.

I wish all my projects compiled in 0.019s

Now you know how long your build time is, follow this article to reduce it.

2. Track app start time

App launch speed is one of the most important factors when creating an app. Users expect apps to launch instantly. Finding the source of a slow launch can be difficult. Outside of using profiler (which I plan to write another post on soon), it can be difficult to gauge what the start up time of your app is, and where to improve it.

One way you can improve the launch time by tracking everything before applicationDidFinishLaunching is called. This is when the app is initializing libraries, setting up ObjC, and loading dylibs. Using this method Xcode will print load times and what is causing them to be slow in the terminal every time you run your app.

Open Product>Scheme>Edit Scheme and under the run action add the following environment variable DYLD_PRINT_STATISTICS and set its value to 1.

Now after every build you should see a print out that looks like this:

To learn more about how to use this information read the Slow Startup Times post by Use Your Loaf.

3. Quick rename

Finding a replacing a variable to rename is always a hassle. Not anymore. Press hold CMD while clicking the variable or function you want to rename. Then from the pop up select rename. It’ll find and rename every copy of it in the project, even in storyboards.

Quick rename in action

Edit: As suggested by Błażej Wdowikowski and James Pamplona, you can quickly renames things in the same scope with the keyboard shortcut cmd+ctrl+e. Not the same as the above, but still useful.

4. Use break points

I know it seems like it is easier to just use print statements, but in many situations it is much easier to just use breakpoints, and it’ll save you time.

To set a breakpoint press the line number on the side of the code you want to stop at, and run your project. Once the code has paused execution on that line you can look at all the surrounding variables values by just hovering over them.

Alternatively you can use lldb to print them in the console with the print object command, for example, po yourVariable.

Break points may seem more complicated, but once you understand some lldb commands and other Xcode debugger tools, it actually saves you a bunch of time because you can stop at a breakpoint without having to rerun your app entirely.

Once you are finished evaluating the values you can press the resume button and disable the break point to prevent it from stopping execution again.

Resume button circled in red

Watch Apple’s 2018 WWDC video on Debugging to learn even more about how to use breakpoints to speed up your workflow. (Including how to run new functions, and set variable values without rerunning the app.)

What are your Xcode debugging tips?

Share your tips in the comments below or tweet them to me @gabriel__lewis

Gabriel Lewis

Written by

iOS @Imgur |