Swift Tips: Debugging Slow Build Times

Blake Merryman
BPXL Craft
Published in
1 min readSep 5, 2017

--

Because Swift’s compiler has to investigate each type before it can continue compiling, build times can become quite slow. If you find that your Swift code is slow to compile, Nick O’Neill of That Thing in Swift shared a few simple steps will help track down the culprits so you can speed things up:

  1. Add -Xfrontend -debug-time-function-bodies to Project Settings > Build Settings > Other Swift Flags.
  2. Build your project (Command + B).
  3. Navigate to the build log and right-click on the build log for your target. Select “Expand All Transcripts” and scan newly visible build times for each section of your code.

Pro Tip: Erick Aderstedt recommends prioritizing your build-time optimizations by choosing “copy transcripts for shown results” and then adding // pbpaste | egrep ‘\.[0–9]ms’ | sort -t “.” -k 1 -n | tail -10 in Terminal.

Have you tried other successful methods for speeding up slow build times in Swift? Let us know in the comments or on Twitter.

For more insights on design and development, subscribe to BPXL Craft and follow Black Pixel on Twitter.

Black Pixel is a creative digital products agency. Learn more at blackpixel.com.

--

--