Swift Tips: Debugging Slow Build Times
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:
-Xfrontend -debug-time-function-bodiesto Project Settings > Build Settings > Other Swift Flags.
- Build your project (
Command + B).
- 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.