28 March 2016

Would you prefer the time it takes to compile and link your app to be faster or slower?

If you are not using a RAM disk, then you may be choosing the latter answer. If you don’t already know how to set this up, I’ve created an easy to use script written in Swift 2.2. This one may best suit the pros but we can all appreciate a little less waiting for a computer.

As a side note, Swift may not currently be the most efficient way to write scripts, but being able to do it has a special kind of sparkle that lights up when it is done.

Using the script allows the Derived Data setting to stay the same in Xcode but runs out of RAM instead of the disk. It does this by mounting the RAM disk to the same path that is normally disk-based.

As an added bonus, Derived Data gets wiped every time a new RAM disk is generated. This helps with some problems related to Derived Data.

This saves wear-and-tear on solid state drives, if you are into that kind of thing. If you happen to be using a spinning disk, it’s way faster than that, too.

I’ve been running Xcode like this for years and over that time all those savings can really add up.

It’s easy to create a launch agent, simply a property list file, that allows having the script run every time your computer starts. I’ve included an example of that in the source code.

I’ve even made sure using this technique works with Instruments because there is a need for Spotlight to find symbol files during profiling and debugging.

The script is contained in an Xcode project. The file main.swift can be copied out and renamed to setupXcodeDerivedDataRAMDisk.swift and placed in a bin directory for running from the command-line or a launch agent.

Here is the link to the project.


Another tip to improve startup times is to change the Debug Information Format.

See Build Settings > Build Options > Debug Information Format.

Change DWARF with dSYM File to DWARF for a slight speed increase during every build.



blog comments powered by Disqus