Xcode has added a great feature to see your application compile in real time but how can you see compile durations for individual classes and then further see what code is causing the slow compile times?
This is helpful but only gets part way there.
Use xctool. When you compile your project on the command line it will emit the time taken to compile each file to the console. e.g:
✓ Compile MySwiftFile.swift (12067 ms)
Additionally, for Swift 1.2 at least there is a flag debug-time-function
which can be passed to the Swift compiler to show you problematic functions.
Further discussion here
Open the Report navigator (Balloon icon left pane). When you build click the top most line with the build hammer and you see the compilation progress for each compiled file.
Swift now includes a function-by-function compiler profiler. You can enable it with the compiler flag -Xfrontend -debug-time-function-bodies
.
Run a clean rebuild and use the grep
command from this post to get a reverse-sorted list of compile time by function.
This was hugely helpful for me - I trimmed maybe 15 seconds off my build time by tuning the slowest-to-compile functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With