Swift Tips: Debugging Slow Build Times

Blake Merryman
Sep 5, 2017 · 1 min read

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.

BPXL Craft

Design and technology articles from the Black Pixel team. blackpixel.com

Blake Merryman

Written by

 Software Engineer

BPXL Craft

Design and technology articles from the Black Pixel team. blackpixel.com

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade