GUI frameworks for .NET – Part 3: Android, iOS, macOS and .NET MAUI
This part of the series is about Microsoft's .NET interfaces that also run on platforms other than Windows, in particular .NET MAUI.
(Image: erzeugt mit KI durch iX)
- Dr. Holger Schwichtenberg
The latest GUI framework from Microsoft has the unwieldy name .NET Multi-Platform App UI – or MAUI for short. However, .NET MAUI is not completely new, but a refactoring and further development of the cross-platform GUI framework Xamarin.Forms, which came to Microsoft through the acquisition of Xamarin in 2016. The new basis is now the modern .NET SDK, but the latest .NET Core Runtime is not always used at runtime; in the case of Android and the Apple operating systems, the Mono Runtime is still used. The new .NET namespace is Microsoft.Maui (previously: Xamarin.Forms).
As part of the "One .NET" strategy, Microsoft integrated the previous Xamarin products Xamarin.iOS (formerly MonoTouch), Xamarin.Mac (formerly: MonoMac) and Xamarin.Android (formerly: MonoDroid) into modern .NET as .NET for iOS, .NET for macOS / Mac Catalyst and .NET for Android in 2022, see the GitHub repositories dotnet/android and dotnet/macios. Despite the outdated name, the last URL is the source for .NET for iOS, Mac Catalyst, macOS and tvOS. The namespaces in these projects are also still the old ones, for example Xamarin.AndroidX.
These GUI libraries form the basis for cross-platform apps with .NET MAUI. It is also possible to write specific apps for the individual platforms with .NET for iOS, .NET for Android and .NET for macOS, based on the platform-specific XML syntax and platform-specific controls. However, this approach is no longer widespread in practice.
In addition, there is also a .NET variant for tvOS in the same repository as .NET for macOS, .NET for Mac Catalyst and .NET for iOS, but this is not supported in .NET MAUI. Microsoft recently removed the old program code to support watchOS from the Xamarin era.
Videos by heise
.NET Multi-Platform App UI (MAUI)
.NET MAUI applications run on Windows (via WinUI 3), macOS (via .NET for Mac Catalyst), iOS (via .NET for iOS), Android (via .NET for Android) and Tizen (this implementation comes from Samsung), see illustration. Unfortunately, Microsoft has left out the Linux desktop. Only an experimental port by Microsoft employee Javier Suárez can be found on GitHub. The associated GitHub issue, which calls for a Linux desktop port, has hundreds of comments but the status "Unanswered".
(Image:Â Holger Schwichtenberg)
While Xamarin.Forms was heavily focused on mobile operating systems, .NET MAUI also includes features specifically for desktop operating systems such as multi-window support, keyboard shortcuts for menus (since version 8.0) and title bar control (since version 9.0). However, integration into macOS via Mac Catalyst is still awkward and not very practical.
With MAUI, you can create compilations for all supported operating systems from a single project via multi-targeting. Conditional compilation allows developers to include platform-specific program code. Multiple header projects, as with its predecessor Xamarin.Forms, are still possible with MAUI. A header project is a concept in multi-platform development. It contains platform-specific code and resources as well as the build configuration for the actual project if it cannot be automatically built for multiple platforms by the framework or tools. The header project contains the start code for the respective platform and loads the actual project.
A prerequisite for the translation for a target platform is the installation of a corresponding .NET SDK workload on the development computer. You can develop for all target systems on Windows computers; when translating for the Apple operating system, however, you also need a Mac computer with XCode for a remote build and an Apple developer account.
The first version of .NET MAUI was released on May 23, 2022 as a supplement to .NET 6.0. The version number of MAUI is aligned with .NET, i.e. in .NET 9.0 there is the fourth version of MAUI with the version number 9.0.
The first two releases (6.0 and 7.0) of .NET MAUI were a challenge for developers because the development experience and performance were often poor and some controls also had bugs at runtime. However, the last two versions are easier to use. Developers who worked with Xamarin.Forms were forced to switch to MAUI because support ended on May 1, 2024. Depending on the features used, there is a lot to do when migrating, but the .NET Upgrade Assistant helps.