Xamarin
02 / 02

Native Compilation, Platform Code & .NET MAUI

Native Compilation, Platform Code & .NET MAUI

Genuinely Native, Not Bridged

Xamarin.iOS ahead-of-time compiles C# to native ARM machine code (iOS forbids third-party JIT compilation); Android has more runtime flexibility. Either way, Xamarin apps run as native code interacting directly with platform APIs — no JavaScript bridge/interpreter layer, unlike some other cross-platform frameworks. This is built on Mono, the open-source cross-platform .NET runtime that made running C# on non-Windows platforms possible in the first place.

Sharing Code, Reaching Native APIs

// shared interface
public interface IBatteryService { int GetLevel(); }

// Xamarin.Android project implementation
[assembly: Dependency(typeof(AndroidBatteryService))]
public class AndroidBatteryService : IBatteryService {
    public int GetLevel() => /* Android-specific API call */;
}

Dependency Services let shared code call platform-specific APIs through a common interface. Xamarin.Essentials covers many common device APIs (geolocation, battery, connectivity) out of the box, reducing how often a custom Dependency Service is needed. Small platform branches can also use #if __ANDROID__/#if __IOS__ directives instead of a full interface.

Custom Renderers

When the shared UI abstraction can't achieve a specific visual/behavioral requirement, a custom renderer drops down to platform-specific native rendering for just that one control, keeping the rest of the UI shared.

Xamarin's Successor: .NET MAUI

Xamarin.Forms has reached end-of-support; .NET MAUI is Microsoft's official successor, unifying more deeply into .NET and extending to desktop (Windows, macOS) alongside mobile. New projects should generally start with .NET MAUI directly; existing Xamarin apps typically plan a migration path.

Keep your own version of these notes — editable, searchable, and organised by your stack.

Start free