When it comes to cross-platform apps, Xamarin has been a popular choice among developers for many years. There is a new contender, however: Microsoft recently introduced the “.NET Multi-platform App UI” (MAUI). While the framework grew out of Xamarin.Forms, it promises to simplify the process of building cross-platform apps even further.
Whether you should switch from Xamarin to MAUI, though, depends on several factors. Let’s dive right in.
What is Xamarin?
Xamarin is a development framework using the programming language C# and has been around since 2011. However, its roots go as far back as 2001, with efforts to develop a Linux version of Microsoft’s .NET Framework.
In 2016, Microsoft bought the company Xamarin, along with the SDK of the same name. Xamarin thus became part of Microsoft Visual Studio, and switched to the open-source MIT license.
With Xamarin.Forms, you can write apps in C# for Android, iOS, macOS, and Windows using a single shared code base. With some additional tweaking in the platforms’ own programming languages, you can achieve near-native performance. This makes it a viable alternative to other cross-platform frameworks like Flutter and React Native.
Recently, Xamarin.Forms was integrated into Microsoft’s .NET MAUI framework.
What is .NET MAUI?
.NET MAUI is Microsoft’s next step towards simplifying cross-platform app development. Like Xamarin, the newer open-source framework lets developers create native user interfaces and applications for iOS, Android, macOS, and Windows using a single codebase.
However, MAUI promises better performance, increased productivity, and a more streamlined developer experience than Xamarin.Forms. It is built on top of .NET 6, which brings improved performance and features across all platforms.
The framework was officially released in 2022 and is planned to replace Xamarin entirely by May 2024, when Microsoft will end support for all Xamarin SDKs.
Differences between Xamarin.Forms and .NET MAUI
Though MAUI is a successor to Xamarin.Forms, there are some notable differences between the two frameworks, which currently still co-exist.
Xamarin.Forms | .NET MAUI |
---|---|
One project per platform | One project for all platforms |
MVVM architecture | MVU architecture |
Workarounds for accessing native resources | Direct access to native platform APIs |
UWP UI (tied to Windows releases) | WinUI (frequent updates) |
One project for all target platforms
With Xamarin, developers have to create a dedicated project for each platform they are developing their app for (Android, iOS, macOS, and Windows). With .NET MAUI, one project covers all platforms, with resources like fonts and images stored in a single location.
MVU instead of MVVM
Model-View-Update (MVU) and Model-View-ViewModel (MVVM) are architectural patterns that separate an app’s presentation logic from its business logic.
While MVVM, used by Xamarin.Forms, is more established among developers, MVU is gaining popularity. Its key advantages are its simplicity and the immutability of the app state. MAUI’s use of MVU makes it easier for developers to add new features without getting into conflict with other parts of the app.
Platform-specific APIs
While Xamarin.Forms provides APIs that work across all platforms, some platform-specific APIs are unavailable or require workarounds. With MAUI, developers can access native functionalities using a set of platform-specific APIs. These include utilizing a device’s sensors, copying and pasting text to the system clipboard, and storing data securely as key-value pairs.
UWP vs. WinUI
Whereas Xamarin.Forms relies on the UWP UI framework, .NET MAUI instead uses WinUI, which is decoupled from the release schedule of Windows. That means developers using MAUI generally have a more current and frequently updated UI framework to work with.
Should you switch from Xamarin.Forms to .NET MAUI?
MAUI still has to prove itself as a cross-platform tool. The Xamarin community, on the other hand, has had many years to get comfortable with its framework of choice. This makes it hard to recommend one over the other on merit alone.
However, support for Xamarin SDKs will end in 2024. Therefore, any new development projects should probably use .NET MAUI, as migrating the code later will present its own issues.
For existing apps, developers should familiarize themselves with MAUI sooner rather than later. While Microsoft removing official support does not spell the end of all Xamarin apps, .NET MAUI is a future-proof option.
Introducing the Scanbot .NET MAUI SDK
We offer Xamarin versions of our Barcode Scanner SDK, Document Scanner SDK, and Data Capture SDK for both iOS and Android. To complement this, our development team is currently working on porting our code to .NET MAUI. When the time comes to switch your app from Xamarin to MAUI, our SDK will be ready to make the switch with you.
Keep an eye on this blog to stay on top of any further developments. We will keep you updated!