0% found this document useful (0 votes)
101 views3 pages

Hacked Up Incremental Compilation in Swift

Hacked Up Incremental Compilation in Swift (2)
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views3 pages

Hacked Up Incremental Compilation in Swift

Hacked Up Incremental Compilation in Swift (2)
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

From:

Subject:
Date:
To:

Andy Matuschak [email protected]


HOWTO: incremental compilation in Swift
December 12, 2014 at 10:14 AM
mobile-team [email protected]

I consider the lack of incremental compilation in Swift to be a critical issue. Its significantly impeding our velocity and certainly damages
psychological health. Frankly, if Id realized Swift compilation was going to be this slow, I probably wouldnt have suggested we start using it.
So Im sorry about that.
But hey, heres a shortcut to incremental compilation. It works specifically in the case that youre iterating on one file and specifically when your
changes in that file cannot affect another file. So: changing an expression inside a function, etc. But thats a really common thing we do when
were iterating.
Unfortunately, making a generic script for this would be a fair amount of work, so theres some manual labor involved for now.
Initial setup
1. Set Xcode to build into a fixed DerivedData locationotherwise every time you blow away DerivedData, youll have to repeat all
these steps. To do that:

1.

1.
2.
3.
4.
5.

1.

Make a new script. Say: quick_compile.sh. Give it the standard #!/bin/bash or whatever at the top and chmod +x it.
Do a clean build of your project.
Go to the Xcode Report navigator (Cmd-8), and choose the report for your recent build.
Type merge into the upper-right hand filter, expand the log for the Merge Khan_Academy.swiftmodule phase, and copy the
contents minus the first line into your script.

1.
2. Do the same for i386.swiftmodule.
3. Do the same for link.
4. Do the same for the file youre iterating on (e.g. ContentItemView.swift); put this at the top of your script.
Iteration
1. Once youve got this set up for a file, just run your script to update the build for that new file.
2. Launch the app with Cmd+Ctrl+R in Xcode.
Youll have to repeat these steps whenever new files are added to the project or to change the file youre iterating on, unfortunately, but its
good when youre working on something focused.
For reference, heres my script (you wont be able to run this directly):

You might also like