Understanding the linker
To keep Xamarin applications small and lightweight for mobile devices, Xamarin has created a feature for their compiler called the linker. Its main purpose is to strip unused code out of the core Mono assemblies (such as System.dll
) and platform-specific assemblies (Mono.Android.dll
and Xamarin.iOS.dll
); however, it can also give you the same benefits if set up to run on your own assemblies. Without running the linker, the entire Mono framework can be around 30 megabytes. This is why linking is enabled by default in device builds, which enables you to keep your applications small.
The linker uses static analysis to work through the various code paths in an assembly. If it determines that a method or class is never used, it removes the unused code from that assembly. This can be a time-consuming process, so builds running in the simulator skip this step by default.
Xamarin applications have the following three main settings for the linker:
Don't Link: In this, the linker...