Back to Blog

Migrating Your Xamarin / Dot Net MAUI Forms App To MAUI

Migrating Your Xamarin / Dot Net MAUI Forms App To MAUI

Xamarin / Dot Net MAUI is now been replaced by MAUI, and this is giving us an idea about where Microsoft is heading with their mobile development ecosystem! The first thing we noticed is that MAUI supports more than just C#/.NET; it also supports Java, JavaScript, Kotlin, and Swift as programming languages for writing the codebase! This means that you can now use any language that you want while still being able to deploy it on iOS or Android devices!

The major difference between Xamarin / Dot Net MAUI and MAUI is that in MAUI the latter runs in a web view instead of using native UI components. The main advantage here is that it allows developers to build their applications using C# or F# and then deploy them on any platform without having to install anything locally or wait for approval from Apple or Google.

Why you should migrate from Xamarin to MAUI.

  • MAUI is Faster – Xamarin takes a lot of time to build and run the app, while MAUI runs faster than Xamarin.
  • MAUI is Easier to Use – You don’t have to go through so much effort in learning how to use MAUI, it is easy to understand and use.
  • MAUI has More Features than Xamarin – With the help of MAUI, you can create apps that are more interactive and engaging with its wide variety of features like Chat, Video Calling, Live Map, etc.
  • MAUI is More Secure than Xamarin – The security in MAUI is better than that of Xamarin as it has some restrictions on the usage of some APIs which makes it safer for users as well as your app data.

A quick comparison: MAUI vs Xamarin

  • Both offer shared code between iOS and Android.
  • Xamarin’s code is more verbose than MAUI’s, but Xamarin has been around longer.
  • Xamarin has more support for complex functionality like maps and in-app purchases.
  • MAUI has a better designer, which makes it easier to build layouts and interact with them in code.

MAUI has the following advantages over Xamarin Forms:

  • Better performance: It is more lightweight than Xamarin Forms, so there will be better performance in terms of memory and CPU usage.
  • Building native UI: You can create the same look and feel of your application as compared to other platforms such as Android or iOS by using the same platform-specific code.
  • Code-sharing: You can share most of your code with other platforms and use it across all platforms including iOS, Android, and Web Applications (using React Native).

Migrating your Xamarin Forms apps to MAUI

The steps we’ll be taking are:

  • Planning: Deciding what features to support in your migration and what to leave out.
  • Migrating: Converting your existing Xamarin. Forms app into a MAUI application that runs on Android and iOS.
  • Reviewing: Check your new application to make sure it’s working as expected.

Before migrating from Xamarin. Forms to MAUI, you need to create a plan and decide on the following points:– What is the goal of this migration?  The main goal of this migration is to reduce the cost of development and maintenance of mobile apps.– Do you want to maintain your current codebase or rewrite it? If you want to maintain your current codebase, then you can use a tool like Visual Studio Code or Xamarin Studio to migrate your existing codebase into MAUI. If you want to rewrite an application completely, then we recommend starting with a blank project and rewriting it from scratch using MAUI.

The following steps should help you plan your migration:

1. Download the latest version of Visual Studio 2022 preview, Microsoft Edge WebView2, and Single-project MSIX Packaging Tools extensions for your development platform and install them.
2. Create a new project or open an existing one in Visual Studio 2022.
3. Right-click the project in Solution Explorer and select Add->New Item… from the context menu, or press Ctrl+Shift+A on Windows or ⌘+Shift+A on macOS.
4. Select MAUI App as the type of new item to add, then choose Mobile App (Xamarin) as the template.
5. Identify all Xamarin. Forms UI elements in your app that require updating, such as pages, controls, views, etc. It’s likely that most of these will already be present in MAUI (for example, the Master view). If they are not present yet then add them now so they can be updated later on. The next step is to decide how you want to handle your Xamarin. Forms project structure. For example, if all of your projects are already split up into platform-specific folders (e.g., Common, iOS and Android), then it might not make sense for you to keep them separated during the migration process. Instead, it might be easier for you to merge them together into one folder (e.g., Common). You can also choose whether or not you want each platform-specific folder to contain one or more subfolders (e.g., Common/iOS/Frameworks)
6. Update these elements so they work in MAUI – this includes adding relevant attributes such as the [Maui] attribute or updating the code behind if necessary. For example, if you have an existing Page in Xamarin. Forms with a Content Page type, then replace this with a Maui Page type in MAUI. (Note: The Maui Page type is similar but not identical to Xamarin.
7. Then make sure you have converted your projects from .NET-framework to .NET SDKs styles.
8. Check all namespaces and incompatible NuGet packages are updated correctly.
9. Address any broken API changes- Ensure that your Xamarin app is not using any outdated APIs like theme packages, data pages or Xamarin. forms.
10. Move all files from Xamarin. forms to your new app project and save it for all platforms that you’re targeting. Change the Target Platforms dropdown at the top of the page from Any CPU/Any Device/Any OS/Universal Windows Platform (UWP) to Any CPU/Any Device/iOS/Android ™ .
11. Review the entire app that you’re migrating and check out whether the layout of every screen is correct. If it’s not, make appropriate adjustments and fix all the bugs.
12. Lastly restore Native platform difference if required and then save your application as a single project file.

Takeaway

As a summary, MAUI is the way to go for developing cross-platform apps. With the MAUI approach, you get more functionality and API support, which in turn makes it easier to develop apps with a native look and feel. On top of that, MAUI is actively supported, unlike other outdated Microsoft platforms that only receive some attention from the community. MAUI is the future for building cross-platform mobile applications and it’s a great framework to help your Xamarin Forms app feel faster and more modern. It’s easy to get started with and can give your app the polish it needs to stand out in the Xamarin ecosystem.

We can help migrate your existing Xamarin apps to MAUI. Connect with us today for a free quote.

Supreet Tare

Sign up Now

Do you have a project in mind? Subscribe to the newsletter and get info, tips and suggestions on how your idea can succeed

Thanks for joining our newsletter.
Oops! Something went wrong.