Key Takeaways
- Companies increasingly need to build client apps that work on multiple operating systems. For developers who wish to use their existing C# and XAML skills to build such apps, this means using either the Uno Platform or Xamarin.Forms.
- Xamarin.Forms and the Uno Platform have more in common than what separates them.
- The future of Xamarin.Forms will be .NET MAUI (Multi-platform Application UI.) MAUI is both the next version of Xamarin.Forms and a completely new product.
- The future of the Uno Platform will build upon Project Runion and WinUI 3. These are Microsoft's solutions for the future of native Windows development and still early in their development.
- The key differentiator between the Uno Platform and Xamarin.Forms is support for WebAssembly. The Uno Platform has it, but Xamarin.Forms doesn't.
- A few scenarios force the choice between frameworks, but it's mostly a case of sticking with the option closest to what developers are most familiar with and personal preference.
Building an application for just one operating system (OS) is now the exception and not the norm. It is rarely appropriate to make different versions of an app for each OS.
Developers and businesses benefit when an app only needs to be written once but can run in more than one place. Being able to reuse known languages and tooling is also appealing.
In the Windows/.NET world, two frameworks enable this Xamarin.Forms; and the Uno Platform. Both allow using C# and XAML to create the app, and they share infrastructure and Visual Studio tooling to build apps for multiple operating systems from a Windows PC.
It can be challenging to know where they differ or to choose the most suitable for use when creating a new cross-platform project with so much in common.
This article explains the differences, similarities, and relationships between Uno Platform and Xamarin.Forms. We'll look at what the future holds for both these platforms and how to choose between them.
I recently helped a company decide which to use for a new project. There were solid arguments for both options, and each was suitable.
I'll tell you which they chose and why, but we'll first look in detail at the two options.
What is Xamarin.Forms?
Xamarin.Forms is a Microsoft-owned, open-source technology that allows developers to build apps for mobile devices. It does this by providing an abstraction over the native Xamain.Android and Xamarin.iOS libraries that provide .NET mappings to the APIs of each platform.
The primary focus of Xamarin.Forms is with building Android and iOS apps. It also supports tvOS and watchOS, has some support for Windows (via UWP), and offers community-maintained support for macOS, Tizen, WPF, and WebAssembly.
Xamarin.Forms has tooling support in Visual Studio on Windows and in Visual Studio for Mac on a Mac. It allows building apps with C#, with or out without XAML, and with F#.
What is the Uno Platform?
The Uno Platform (or just Uno) is an open-source solution that allows developers to write C# and XAML code once and then compile it for multiple platforms. Rather than creating a new abstraction over supported platforms, it maps the APIs and UI controls from UWP.
It supports building apps that run on UWP, Android, iOS, macOS, and WebAssembly. It has recently started adding support for Linux, Tizen, and WPF.
Uno also uses Xamarin.Android, Xamarin.iOS, and Xamarin.Mac for access to the native functionality on those operating systems but uses custom solutions for the other platforms.
Uno also has tooling support for Visual Studio on Windows and Visual Studio for Mac on a Mac.
Yes, there are a lot of similarities, and they both:
- Are open-source (but with paid support available)
- Support Android and iOS
- Support other platforms to varying degrees
- Allow writing apps with C# and XAML
- Work with Visual Studio on Windows and Mac
It's the differences that can help distinguish them.
- Xamarin.Forms is owned and backed by Microsoft, while Uno is backed by NVentive (A Canadian company)
- Uno chose to reuse the existing UWP APIs, while Xamarin.Forms created new, platform-agnostic abstractions for the underlying functionality.
- Xamarin.Forms is highly focused on "Mobile" apps, while Uno wants to be "everywhere."
- Although both projects were started at roughly the same time, Xamarin.Forms has been open-source from its start (in 2014), while Uno became open in 2018. As a result of this, Xamarin.Forms has a more extensive user base, more comprehensive API support, and broader support from the community and 3rd party control vendors. However, community and vendor support for Uno is growing.
The future
The other significant distinguishing factor is what the future holds for each of these solutions.
Uno is based on UWP, but WinUI3 is replacing UWP. WinUI3 is the next (third--depending on how you count them) generation of Windows UI technology. It is part of Project Reunion, Microsoft's attempts to redefine, open up, and unify the development story for Windows. WinUI3 will have some significant changes for Windows developers, and Uno will likely need to do a lot of work to keep up with the changes. That WinUI3 is a long-term project and is still at least six months from its 1.0 release. Fortunately, the core team at Uno has a strong partnership with Microsoft, which includes granting them access to WinUI3 code that isn't open-source (yet.) This relationship has allowed Uno to release compatible versions on the same day as the last few WinUI3 preview releases.
While WinUI focuses exclusively on building the best platform it can for Windows, Uno extends this to take "WinUI everywhere."
The future for Xamarin.Forms is more complicated. Version 5.0 of Xamarin.Forms was released at the end of 2020 and will be the last under that name. The Multi-platform Application UI (MAUI) is coming in November 2021 as part of .NET 6. In many ways, this will be version 6 of Xamarin.Forms and will include a simple migration path for existing Xamarin.Forms apps. However, MAUI is having a significant overhaul internally, and there are many changes planned, which risk making it more equivalent to a first version project. The MAUI team is still working out how to implement all the proposed changes, and a November release date looks worryingly close with this in mind. I'm sure the date will be met but will features or quality suffer as a consequence.
As part of .NET 6, MAUI will gain access to some new capabilities. The most notable is the ability to have a single project that can target all desired platforms. This change will significantly simplify the development experience. However, once the underlying tooling makes this available to MAUI apps, we can expect Uno to take advantage of this too.
The other significant change that MAUI will bring is a broadening of the scope from Xamarin.Forms to equally support developing apps for desktop and mobile. It closes a notable gap with Uno by officially supporting building apps for Android, iOS, Mac, and Windows.
WebAssembly is the key differentiator
With both tools offering desktop and mobile coverage, the big differentiator becomes the web, which Uno supports by creating a WebAssembly version of the app.
MAUI won't support outputting WebAssembly versions of apps. Microsoft is taking the opposite approach when it comes to supporting WebAssembly in combination with native applications.
Microsoft has a separate tool for creating WebAssembly apps in Blazor and will provide a way to package Blazor web apps for the desktop as a "Blazor Desktop" app that MAUI will power. Additionally, the experimental Blazor Mobile Bindings project allows converting a Blazor web app into a native mobile app powered by Xamarin.Forms.
If you want an app that runs natively on devices and the web, Microsoft wants you to start with Blazor.
How to choose
The similarities between the two options and the uncertainty about the future can make the decision seem daunting, but some scenarios point to one option over the other.
- If you already have a Xamarin.Forms app - stick with that.
- If you have an existing UWP app - go with Uno.
- Want to have a WebAssembly version and stick with using XAML to create the UI - use Uno.
- Suppose you have an existing Xamarin.Forms app but want to extend that to WebAssembly - Uno offers a hybrid approach that takes the UWP version of a Xamarin.Forms app and turns that into a WebAssembly app.
- If you only consider something that Microsoft produces - then you're forced to use Xamarin.Forms.
- If you want to run on Linux - go with Uno.
For all other scenarios, the decision becomes more complicated. There are some APIs that Xamarin.Forms makes available that Uno doesn't (yet), but we can expect those gaps to close in the future. A quick check for the availability of the functionality the app needs can decide for you; otherwise, it comes down to personal preference.
The possibility of making the wrong decision doesn't worry me. While changing the framework once development is underway wouldn't be desirable, it wouldn't require starting again from scratch. Both frameworks support the same architectural and design patterns and enable rapid application development. I'd expect to move large amounts of code to the restated project with only minimal changes.
At the start of the article, I said that I was recently involved in choosing the technology for a new project, and there was no clear reason to choose one or the other. The company wants a brand new app that will initially run on Android and iOS, but Windows support may be added in the future. It will be written in C# and XAML and will communicate with an existing backend written in C#/ASP.NET. While a large app, there is no functionality required that uses obscure device APIs or functionality.
Either option would work, but the company chose to go with Uno. They choose Uno because:
- Their staff has more experience with UWP XAML and APIs than with Xamarin.Forms.
- They're a small company but making an impact in their industry. They know how effective a small dedicated company can be when they desire to be big and see lots of exciting potential in Uno and the company behind it.
- While they won't release a web-based version of the app, having one during development allows key stakeholders to see progress easily. No messing around with distributing, installing, and managing preview builds of apps. All anyone needs to do is visit an internal website to see the latest version.
These reasons won't apply to every company or project, but because there is a choice, this company gets to have something that better meets their needs.
The choice is beneficial for all of us. Only having one option makes the decision straightforward, but it decreases the likelihood that it will be the best fit for what we need. Choosing between Uno and Xamain.Forms/MAUI isn't always easy, but it's better than not having a choice.
About the Author
Matt Lacey is a consultant/freelance developer with more than 20 years of experience building apps for mobile devices and Windows PCs. He's a Microsoft MVP in Windows Development, a contributor to multiple open-source projects, and is currently writing his second book. The book introduces developers to building with the Uno Platform and will be published by Packt later this year.