How to speed up MonoTouch compilation time?

Build Time Improvements in Xamarin.iOS 6.4

Xamarin.iOS 6.4 has significant build time improvements, and there is now an option to only send updated bits of code to the device. See for yourself:

Built time improvements
(source: xamarin.com)

Read more and learn how to enable incremental build in Rolf’s post.

Evolve 2013 Video

An updated and expanded version of this content can be seen in the video of the Advanced iOS Build mechanics talk I gave at Evolve 2013.

Original Answer

There are several factors affecting build speed. However most of them have more impact on device builds, including the use of the managed linker that you mentioned.

Managed Linker

For devices then Link all is the fastest, followed by Link SDK and (at the very end) Don’t link. The reason is that the linker can eliminate code faster than the AOT compiler can build it (net gain). Also the smaller .app will upload faster to your devices.

For simulator Don’t link is always faster because there’s no AOT (the JIT is used). You should not use other linking options unless you want to test them (it’s still faster than doing a device build).

Device tricks

  • Building a single architecture (e.g. ARMv7) is faster than a FAT binary (e.g. ARMv7 + ARMV7s). Smaller applications also means less time to upload to device;

  • The default AOT compiler (mono) is a lot faster than using LLVM compilers. However the later will generate better code and also supports ARMv7s, Thumb2;

  • If you have large assets bundled in your .app then it will take time to deploy/upload them (every time since they must be signed) with your app. I wrote a blog post on how you can workaround this – it can save a lot of time if you have large assets;

  • Object file caching was implemented in MonoTouch 5.4. Some builds will be a lot faster, but others won’t be (when the cache must be purged) faster (but never slower ;-). More information why this often happens here).

  • Debug builds takes longer because of symbols, running dsymutil and, since it ends up being larger, extra time to upload to devices.

  • Release builds will, by default (you can turn it off), do a IL strip of the assemblies. That takes only a bit of time – likely gained back when deploying (smaller .app) to the device.

Simulator tricks

  • Like said earlier try to avoid linking since it will take more time and will require copying assemblies (instead of symlinking them);

  • Using native libraries is slower because we cannot reuse the shared simlauncher main executable in such cases and need to ask gcc to compile one for the application (and that’s slow).

Finally whenever in doubt time it! and by that I mean you can add --time --time to your project extra mtouch arguments to see a timestamp after each operation 🙂

Leave a Comment