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.
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.
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
- 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 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
- Supported ABIs
- Select the ABI for the targeted device
- E.g. if you’re deploying to an x86 emulator, only select the x86 ABI
NOTE: This is an experimental setting!
AndroidExplicitCrunchto the Droid
- 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
- 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.
- 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 to all who have helped contribute to this doc!