Xamarin is a Microsoft framework for building iOS and Android apps in C#, compiled to native ARM binaries on the Mono runtime. The SDKs are in maintenance mode now that .NET MAUI succeeds Xamarin.Forms, but many production apps still run on them.
Key takeaways
- Architecture: Xamarin apps run on the Mono runtime, and iOS code compiles ahead of time to native ARM.
- Choice: The key decision is Xamarin.Forms, now evolved into .NET MAUI, or Xamarin.Native.
- Sharing: 2 primary code-sharing strategies exist, each with its own trade-offs.
- Migration: Microsoft has superseded Xamarin with .NET MAUI, so plan a migration path.
- Dev Station: Dev Station supports Xamarin apps and migration to .NET MAUI for US and UK teams.
Why does Xamarin still matter for cross-platform mobile development?
Xamarin, acquired by Microsoft in 2016 and now part of the .NET ecosystem, compiles C# into native ARM binaries for iOS and Android. Unlike hybrid frameworks that wrap a WebView, Xamarin provides direct access to native platform APIs while letting you share business logic, networking code, and data models across platforms. The result is native performance with a single-language codebase.
With .NET MAUI succeeding Xamarin.Forms, the original Xamarin SDKs remain in maintenance mode, but thousands of production apps still run on them, and the architectural patterns Xamarin introduced carry directly into MAUI. Understanding Xamarin is a prerequisite for maintaining those apps and for making informed decisions about migration.
How is a Xamarin app architected?
Xamarin apps run on the Mono runtime on non-Windows platforms. On iOS, the Ahead-of-Time (AOT) compiler translates C# into native ARM code that the Apple App Store accepts. On Android, the Mono runtime sits alongside the Dalvik/ART runtime, and C# code calls Java libraries through JNI bindings that Xamarin generates automatically.
Shared Code Layer
Business logic, data access, view models, and networking live in a shared .NET Standard or .NET library project. This layer has zero platform-specific references.
Platform Bindings
Xamarin.iOS and Xamarin.Android provide 1:1 bindings to the full native SDK. Any API available in Swift or Kotlin is accessible from C# with the same signature and semantics.
Mono Runtime
On iOS, AOT compilation eliminates the JIT at runtime. On Android, the Mono VM co-exists with the ART VM, and the Xamarin JIT handles dynamic code paths while still supporting AOT for startup performance.
Platform Projects
Each target (iOS, Android, Windows) has its own head project with platform-specific UI, startup code, and dependency registration. These projects reference the shared layer.
Key Insight: Xamarin does not interpret or wrap a WebView. The C# compiler produces the same native instructions as Swift or Kotlin compilers. The Mono runtime is only needed for garbage collection and platform abstraction, not for executing your code.
Should you choose Xamarin.Forms or Xamarin.Native?
The single most important architectural decision in a Xamarin project is choosing between Xamarin.Forms (now evolved into .NET MAUI) and Xamarin.Native. Both approaches compile to native code; they differ in how you build the UI layer.
Xamarin.Forms
Abstract UI layer with XAML markup. Write once, render natively on each platform. Controls map to native widgets, a Button renders as UIButton on iOS and Android.Widget.Button on Android.
Xamarin.Native
Migration Note: Xamarin.Forms has evolved into .NET MAUI. New projects should start with MAUI. Existing Xamarin.Forms projects can migrate incrementally, the XAML and C# patterns are largely compatible, but the renderer architecture has been replaced by a handler architecture.
Which code sharing strategies work best?
How you structure shared code determines maintainability, testability, and the speed of adding new features. Xamarin supports two primary strategies, each with distinct trade-offs.
Shared Project (SAL)
The Shared Asset Library uses compiler directives (#if __IOS__, #if __ANDROID__) to include platform-specific code within a single project. The IDE compiles the shared code directly into each platform head.
- Simple to set up, no additional project references
- Conditional compilation fragments the codebase and reduces readability
- Best for small prototypes or when platform divergence is minimal
.NET Standard / .NET Library
A compiled class library (historically PCL, now .NET Standard 2.0+ or .NET 6+) that both platform heads reference. Platform-specific behavior is injected via interfaces and DependencyService or a DI container.
- Compile-time type safety across the entire shared layer
- Clean separation of concerns. Platform code stays in platform projects
- Recommended for any production app of moderate complexity
| Factor | Shared Project | .NET Standard Library |
|---|---|---|
| Code Reuse | High (but fragile with directives) | High (via interfaces and DI) |
| Testability | Difficult, cannot unit-test shared project directly | Full. Library is a standard .NET assembly |
| Refactoring Safety | Low, compiler directives bypass type checks | High, compiled with full type checking |
| NuGet Distribution | Not possible | Supported, can package as NuGet |
Which UI development patterns should you use?
Whether you choose Xamarin.Forms or Xamarin.Native, the UI layer benefits from established patterns that separate presentation logic from business logic.
MVVM (Model-View-ViewModel)
The dominant pattern in Xamarin. Views (XAML or native) bind to ViewModel properties via INotifyPropertyChanged. Commands handle user actions. The ViewModel has no knowledge of the View, which enables unit testing without a UI.
Data Binding
Xamarin.Forms provides built-in data binding between XAML elements and ViewModel properties. One-way, two-way, and one-way-to-source modes control data flow. Compiled bindings catch errors at build time.
DependencyService / DI
Register platform-specific implementations against shared interfaces. The runtime resolves the correct implementation for the current platform. For production apps, prefer a full DI container (Autofac, DryIoc, Microsoft.Extensions.DependencyInjection) over the built-in DependencyService.
Custom Renderers / Handlers
Performance Tip: Use compiled bindings (x:DataType in XAML) instead of reflection-based bindings. Compiled bindings resolve at build time, eliminate runtime type lookups, and surface binding errors in the compiler output rather than at runtime.
How do you test Xamarin applications?
A testable architecture is one of the strongest advantages of Xamarin over native development. The shared .NET Standard library is a standard .NET assembly. You can test it with the same tools and frameworks you use for any .NET project.
Unit Testing
Test ViewModels, services, and business logic with xUnit, NUnit, or MSTest. Because the shared layer has no platform dependencies, tests run on any .NET runtime, no emulator or device required.
- Target the shared library project directly
- Mock platform dependencies with Moq or NSubstitute
Integration Testing
Verify that platform-specific implementations work correctly with the shared layer. Run tests on real devices or emulators using the platform test runner.
- Use xUnit runner for iOS and Android
- Test DependencyService resolution and platform API calls
- Validate SQLite, file system, and network operations on-device
UI Testing
Automated UI tests simulate user interactions across the app. Xamarin.UITest (now open-source) integrates with App Center and local test runners.
- Write tests in C# using the UITest framework
- Query elements by automation ID, class, or marked text
- Run on cloud device farms (App Center Test, Firebase Test Lab)
| Test Type | Scope | Runs On | Speed |
|---|---|---|---|
| Unit | ViewModels, services, models | Desktop / CI | Fast (ms) |
| Integration | Platform implementations, DI resolution | Device / Emulator | Medium (seconds) |
| UI / E2E | Full user flows, navigation, rendering | Device / Cloud | Slow (minutes) |
How do you build and deploy a Xamarin app?
Shipping a Xamarin app involves platform-specific build pipelines, signing requirements, and store submission processes. The shared codebase means you build once and package for each target.
CI/CD Pipeline
Use Azure DevOps, GitHub Actions, or App Center to automate builds. Each pipeline runs MSBuild for the shared library and platform heads, runs unit tests, and produces signed packages.
iOS Signing
Requires an Apple Developer account, provisioning profile, and distribution certificate. The IPA is built on macOS with Xcode installed. Fastlane automates certificate management and screenshot capture.
Android Signing
Sign the APK/AAB with a keystore. Google Play requires AAB format. Upload the signing key to Google Play App Signing for managed key rotation. The Android SDK and JDK must match the target of the project framework.
Store Submission
App Store Connect (iOS) and Google Play Console (Android) each require metadata, screenshots, privacy URLs, and review compliance.
Build Size Note: Xamarin apps include the Mono runtime, which adds approximately 3 to 5 MB to the final package size. Linker settings (SDK assemblies only vs. all assemblies) significantly affect output size. Use the linker in release builds and enable AOT + LLVM on iOS for smallest binaries.
What is the migration path to .NET MAUI?
Microsoft has officially superseded Xamarin with .NET MAUI (Multi-platform App UI). Understanding the migration path is critical for teams maintaining existing Xamarin apps or planning new cross-platform investments.
Assess Current State
Audit your Xamarin.Forms version, custom renderer count, and platform-specific code volume. Apps with few custom renderers and standard controls migrate most smoothly. Heavy native interop requires more effort.
Update to Latest Xamarin.Forms
Upgrade to Xamarin.Forms 5.0 before migrating. This version is closest to the MAUI API surface and introduces compatibility shims. Fix any deprecation warnings at this stage.
Convert Renderers to Handlers
MAUI replaces custom renderers with a handler pattern. Each handler maps a single cross-platform property to a native view change, no subclassing the entire native control. This is the most labor-intensive migration step.
Adopt the Single Project Model
MAUI uses a single project with platform-specific folders instead of separate head projects. Move platform code into Platforms/iOS, Platforms/Android, and Platforms/Windows directories.
| Concept | Xamarin.Forms | .NET MAUI |
|---|---|---|
| Project Structure | Separate head projects per platform | Single project with platform folders |
| UI Customization | Custom Renderers | Handlers |
| Target Framework | Mono / .NET Standard 2.0 | .NET 6+ (single BCL) |
| Layout Engine | Xamarin.Forms layout system | Same core, optimized rendering |
| Hot Reload | XAML Hot Reload (limited) | Full Hot Reload (XAML + C#) |
What are the next steps?
Whether you are starting fresh, maintaining an existing Xamarin app, or planning a migration to MAUI, the following actions will set you on the right path.
New Projects: Start with .NET MAUI
Do not start new projects on Xamarin.Forms. Use .NET MAUI for the single-project model, handler architecture, and ongoing Microsoft support. The XAML and MVVM patterns transfer directly.
Existing Xamarin Apps: Audit and Plan
Inventory your custom renderers, platform-specific code, and third-party library dependencies. Create a migration timeline aligned with your release cadence. Prioritize renderer-to-handler conversion.
Invest in Shared Logic
Move as much code as possible into .NET Standard / .NET libraries with clean interfaces. The more logic lives in shared, testable assemblies, the easier both maintenance and migration become.
Automate Your Pipeline
Set up CI/CD with Azure DevOps or GitHub Actions. Automate builds, unit tests, and distribution to internal testers. Manual builds are the enemy of shipping velocity.
Bottom Line: Xamarin proved that C# developers can build truly native mobile apps without sacrificing performance or API access. .NET MAUI continues that mission with a modernized architecture. The investment you make in shared code, MVVM patterns, and testable architecture pays dividends whether you stay on Xamarin or migrate forward.
Frequently asked questions
Five questions come up most often on this topic.
Is Xamarin still supported?
The original SDKs are in maintenance mode because .NET MAUI succeeded Xamarin.Forms, so new projects should start on MAUI.
What is the difference between Xamarin.Forms and Xamarin.Native?
Xamarin.Forms shares UI code across platforms, while Xamarin.Native builds each platform UI separately on a shared logic layer.
How do you share code in Xamarin?
Through a shared .NET Standard library, using one of two primary strategies with different trade-offs.
How do you test a Xamarin app?
The shared library is a standard .NET assembly, so you can test it with standard .NET tools.
Should I migrate to .NET MAUI?
Yes for apps with a long future, because Microsoft has officially superseded Xamarin and an early plan lowers risk.
Dev Station Technology builds and migrates .NET and cross-platform mobile apps for teams in the United States and the United Kingdom, with scoped estimates and contracts agreed per engagement. Device and telemetry data stays in your own cloud tenant, in the region your policy requires. Where a client needs SOC 2, HIPAA or UK GDPR evidence, we build the technical controls those frameworks ask for and work alongside the assessor who issues the certificate.
Want an AI assistant to summarize or cite this guide?
Click any link below to open the AI with a pre-filled prompt referencing this article:
Talk To Us
Tell us what you are building and what it has to connect to. An engineer answers, and you get a straight view of what the work would take.
Get In Touch →Related articles
Contents
Subscribe To Our Newsletter