Skip to content
Tips and tricks on how to speed up the time it takes to compile a Xamarin app
Branch: master
Clone or download
Latest commit 1fc5d39 May 15, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
License.md Create License.md Jun 10, 2017
README.md Update README.md May 15, 2019

README.md

Purpose

Sometimes Xamarin Build times can take a long time, adding delays to our development timeline. Below are tips to reduce the compilation time for Debug Configuration builds.

The screenshots below were created on 10 June 2017 using Visual Studio for Mac v7.0.1 and UITestSampleApp.

Disclaimer

These recommendations are only meant for Debug Configuration builds. They will reduce the time for each compilation, but may increase the size of the app and decrease the performance and load-time of the app.

I highly recommend utilizing the Linker for Release Configuration builds; Link SDKs and Frameworks is my recommended minimum setting. I also highly recommend heavily testing the Release Configuration build of the app because the app may behave differently when the Linker is utilized.

Additional Resources

Xamarin Videos

Xamarin.iOS Documention

Xamarin.Android Documentation

iOS Build Settings

iOS Build Settings

  • Linker behavior: Don’t Link for Simulator Builds, Link on Devices Builds

    • The Linker will reduce the amount of managed code which means less native code to AOT compile
    • Simulator builds don't AOT compile, but Device builds do AOT compile
  • Enable incremental builds

    • Allows the AOT compiler to compile only the code that changed
  • Enable device-specific builds

    • This encourages the compiler to only compile for the targeted device

    • This allows you to select many supported architectures

    • Selecting multiple architectures without enabling device-specific builds will cause compilation to take longer

      - X86_64 Architecture works for iPhone Simulators 5s and newer
      - i386 Architecture works for iPhone Simulators earlier than the iPhone 5s
      
  • Optimize PNG Images

    • The compiler will take extra time to complete the optimizations

Android Build Settings

General

Android Build Settings, General

  • Use Shared Mono Runtime
    • This will install Mono on the targeted device
    • Installing Mono on the device means that Mono doesn't have to be bundled in the APK, making the APK quicker to compile and deploy
  • Fast Assembly Deployment
    • Deploys assemblies to a directory on the device instead of bundling them in the APK
    • The APK compiles faster, is smaller, and is faster to deploy
    • Allows Xamarin to deploy individual changed assemblies instead of rebuilding/redeploying the entire APK

Linker

Android Build Settings, Linker

  • Linker Behavior: Link SDK assemblies only
    • The Linker will reduce the amount of managed code which means less native code to compile
    • Because Android uses emulators which behave similarly to Android devices, there isn't a recommended difference between Emulator & Device builds for the Linker settings like there is for iOS

Advanced

Android Build Settings, Advanced

  • Supported ABIs
    • Select the ABI for the targeted device
    • E.g. if you’re deploying to an x86 emulator, only select the x86 ABI

CSPROJ

Android CSProj File

NOTE: This is an experimental setting!

  • Add AndroidExplicitCrunch to the Droid csproj file
    • When this property is set, the build process pre-crunches the .png files
    • Requires Xamarin.Android 7.0+
    • If you are building an app with a very large number of local drawables, an initial build (or rebuild) can take minutes to complete. To speed up the build process, set AndroidExplicitCrunch property to true in the csproj file.
    • It is not known if this setting will truly speed up your build. Time your initial build, and then a second build with no changes. Make the call if the setting helps your app or not.

Project References

Edit References

  • Use shared projects instead of .NET Standard libraries
  • Compilation time increases for every referenced .NET Standard library
    • Referenced .NET Standard libraries will compile first, then the Startup Project will compile
    • Using Shared Projects allows the project to compile faster

Thank You

Thank you to all who have helped contribute to this doc!

You can’t perform that action at this time.