Maximize Your Mobile App’s Potential with .NET MAUI: A Migration Guide

Henk Kok

The Xamarin chapter is closing, with the end-of-life announcement ringing in changes across the board, especially with Xcode’s support shifts. Migrating to .NET MAUI isn’t just about keeping up; it’s about tapping into the full spectrum of the .NET ecosystem’s power—think quicker load times, more efficient memory use, and a unified codebase that stretches from mobile to desktop.

Here at Xablu, we’re in the business of making transitions like these as smooth as coding on a good day. We support your team with the migration of the Xamarin code, spot what needs to evolve on the UX side, and set you on a clear, efficient path to .NET MAUI. With an eye on the latest best practices, we’re talking about aligning with industry standards, and streamlining your process with Agile methodologies. Plus, we don’t just stop at code—UX design, DevOps and sharpening your strategic approach with OKRs are part of the package, ensuring that your app doesn’t just work well, but also aligns with business and user needs, looks good and ships fast.

So, ready to get started? Keep reading to find out how to make your app’s move to .NET MAUI as straightforward as it is smart.

Table of Contents

Why it's Time to Move On

Let’s face it, Xamarin has been around for more than 10 years now. It’s been a solid pick for building cross-platform apps for many teams. But all good things must evolve, and Xamarin’s no different. With Microsoft sounding the end-of-life alarm for Xamarin, it’s clear the torch is being passed to .NET MAUI. And here’s the kicker: this isn’t just about keeping your apps on life support—it’s about introducing a whole new vision on cross platform, spanning more operating systems than ever.

.NET MAUI comes armed with a .NET 8 engine under the hood and a suite of new tools. It’s not just about maintaining the status quo; it’s about supercharging your apps. Smoother performance, more robust security measures, and a development experience that’s been polished to shine. And let’s not forget the streamlined workflows that come from a single project structure—no more juggling multiple codebases.

But why rush the migration? Well, staying put on Xamarin means you’ll soon will not be able to publish a new version in the app stores. Think about it: no more updates, no more cutting-edge features, and slowly but surely, a widening gap between your app and the current tech standards. On the other hand, making the move to .NET MAUI puts you back in the driver’s seat, with all the support, tools, and performance gains to keep your app racing ahead.

So, whether it’s the lure of enhanced features or the push of Xamarin’s end-of-life, now’s the time to gear up for migration. And hey, it’s not a solo journey—you’ve got a roadmap and a community of fellow developers to help navigate the path to .NET MAUI. Ready to roll? Let’s get your apps set for the future.

Advancements and Improvements in .NET MAUI

 

With the upgrade to .NET 8, .NET MAUI is not just a necessary step; it’s an opportunity to leverage the suite of enhancements that .NET 8 brings to the MAUI framework. Here are some of the most significant technical advancements in .NET MAUI that your software team can take advantage of:

  1. Quality Focus: The primary aim for .NET MAUI in the .NET 8 release has been enhancing quality, with a significant number of bugs addressed to improve overall reliability.

  2. AOT Improvements: The enhancements to Ahead-of-Time (AOT) compilation, such as Startup tracing or Profiled AOT, which leads to faster application launch times (NativeAOT on MAUI supports iOS) with a minimal increase in app size. 

  3. NuGet Packages: .NET MAUI simplifies package management by consolidating multiple project platforms into a single project. This streamlined approach enhances developer flexibility, allowing for easier management of dependencies and versioning across the unified codebase.

  4. Unified Platform APIs: .NET MAUI’s unification of Android, iOS, macOS, and Windows APIs into a single API enhances developer productivity and application performance.

  5. UI Control Quality: The focus on improving the quality of UI controls, layout, and memory management to provide a smoother user experience across different platforms.

  6. Startup Performance: Notable improvements in startup times for complex applications, with some applications experiencing over a 30% improvement in startup speed.

  7. Multi-window Support: A fundamental change in .NET MAUI is the introduction of the Window as the base foundation for creating multi-window applications, which enhances the desktop app experience.

  8. Android Specific Features: Features like AndroidStripILAfterAOT for smaller assembly sizes and enhanced performance on Android devices.

  9. Build Performance: Improvements such as filtering Android process outputs, porting tasks to C#, and optimizations in remote iOS builds on Windows.

  10. Application Size Reductions: Various performance improvements that also contribute to reducing application size, such as removing unneeded reflection and using StringComparer.Ordinal for collections.

These improvements underscore the technical benefits of migrating to .NET MAUI, positioning it as a forward-thinking framework for building modern, performant applications across various platforms. They represent just a glimpse of the comprehensive enhancements that the .NET 8-based version of .NET MAUI offers, ensuring that your app development is not just up-to-date but also ahead of the curve.

Strategic Integration of OKRs, UX and Agile in .NET MAUI Development

When it comes to adopting .NET MAUI for mobile app development, there’s more to the process than just technical implementation. Xablu provides training and coaching on the introduction of Objectives and Key Results (OKRs), Agile methodologies, and User Experience (UX) design, ensuring these practices are closely tied to the actual technical process. By leveraging best practices, we help create control within an organization and align and communicate customer objectives with Key Results across projects through a blend of training, coaching, and the development of OKR masters within the organization.

OKRs: A Framework for Clarity and Focus Implementing OKRs offers a framework for setting, tracking, and achieving goals across an organization. OKRs enhance transparency, align team efforts with strategic vision, and foster a results-driven culture. They empower teams to focus on collaboratively set initiatives and understand how their individual contributions fit into wider organizational goals.

Kanban: Agile Planning and Execution In many project organizations, Kanban as a planning methodology aligns better than Scrum. It combines pre-established plans (Work Breakdown Structures) with an agile approach, promoting continuous collaboration through better visibility into planned tasks and the establishment of a clear communication structure.

UX: Enhancing the User Journey In .NET MAUI development, the integration of UX, OKRs, and Kanban is crucial. Where possible within a client’s existing communication structures, we implement this approach. Our vision is to deliver a customized, scalable solution that fits the project approach and culture of the client. Incorporating UX, OKRs, and Kanban is key to boosting operational efficiency and strategic execution.

The Role of Design Systems and Component Libraries The use of UX, design systems, and component libraries plays a pivotal role in creating cohesive and functional mobile applications. With .NET MAUI, we can help integrate these elements to ensure that the applications not only meet functional requirements but also deliver a consistent and compelling user experience. Design systems provide a shared language and set of components that streamline the design process, while component libraries offer reusable UI elements that save time and maintain consistency across different parts of one or more apps. Together, they form the cornerstone of a user-centric development approach that can be effectively managed with OKR-driven strategies and Agile execution.

Keeping the User Front and Center

When optimizing for .NET MAUI, the goal is to adapt without interrupting the user’s journey through the application. Each step in the user’s interaction should be coherent with the next, maintaining the narrative of the experience from start to finish. This is crucial because any disruption can lead to dissatisfaction and a break in the seamless experience that users have come to expect​​.

Embracing empathy is one of the major strategies to ensure continuity. By understanding and prioritizing the emotions and behaviors of users, UX professionals can make more informed decisions that align with user expectations. This involves perspective-taking, avoiding judgment, recognizing specific emotions, and taking action to communicate understanding​​.

Furthermore, incorporating UX into the product development process is essential. It’s not just about having a dynamite product; it’s about ensuring that the product is usable and enjoyable through strong UX​​. A holistic approach to UX ensures that every element of the user interface is consistent and contributes to a cohesive experience​​.

However, the pursuit of continuity in UX does not imply a resistance to change. The dynamic nature of technology means that improvements and updates are inevitable. The challenge is to balance these changes with the need for continuity, ensuring that updates enhance rather than disrupt the user experience​​.

To effectively transition existing UX designs to work with .NET MAUI, it’s crucial to utilize the platform’s capabilities. .NET MAUI allows for UI customization across different platforms and devices. This means you can optimize your application to make the most effective use of space on different screen sizes, take advantage of device capabilities like location sensors and cameras, and rearrange UI elements to best suit the input methods of each device​​.

The OnPlatform and OnIdiom markup extensions in .NET MAUI are powerful tools for creating a responsive UI tailored to various platforms and device idioms. OnPlatform allows customization on a per-platform basis, setting values for properties specific to Android, iOS, Mac Catalyst, Tizen, and WinUI, while OnIdiom facilitates customization based on whether the app is running on a phone, tablet, desktop, TV, or watch​​.

DevOps and Migration: Like Peanut Butter and Jelly

In the realm of app development, DevOps and migration to .NET MAUI go hand-in-hand, ensuring a smooth transition and continuous integration/delivery (CI/CD). Embracing DevOps with .NET MAUI simplifies the complexities of building and deploying apps across multiple platforms. Prior to setting up pipelines, necessary files such as signing certificates for iOS, keystores for Android, and package signing certificates for Windows are prerequisites.

The process begins with the creation of pipelines, for which .NET MAUI provides sample pipelines, like those in the Weather21 app, to guide developers through the setup. These starter pipelines, ideal for basic testing and build tasks, integrate seamlessly into DevOps strategies, focusing on essential steps like setting the .NET version, installing MAUI workloads, managing signing files, building/publishing the app, running unit tests, and uploading artifacts.

The dotnet CLI tool streamlines the DevOps workflow, eliminating the need for intricate scripts to manage builds and publications across different frameworks. This tool allows for executing dotnet build and dotnet publish commands for any TargetFramework, contributing to a more efficient CI/CD pipeline. The common tasks for pipelines in both GitHub Actions and Azure DevOps revolve around setting up the .NET SDK version and installing .NET MAUI, demonstrating the alignment of DevOps practices with .NET MAUI’s versatile framework.

The Step-by-Step Migration Playbook

Migrating your Xamarin.Forms app to .NET MAUI is a process made significantly simpler with the .NET Upgrade Assistant. Here’s how to make the transition smooth:

  1. Preparation: Ensure your Xamarin.Forms project is updated to version 5.0 and running on .NET Standard 2.0 or higher for the best results before migration​​.
  2. Installation: If using Visual Studio on Windows, install the .NET Upgrade Assistant from the Extensions menu. For CLI, use the command:
    dotnet tool install -g upgrade-assistant

    To update the tool, use:

    dotnet tool update -g upgrade-assistant

    Note that if you have additional NuGet feed sources configured, you may need to use --ignore-failed-sources to avoid errors​​.

  3. Running the Upgrade: In Visual Studio, right-click on the project and select ‘Upgrade’. For CLI, navigate to your project folder and run:
    upgrade-assistant upgrade

    This will update all eligible files within your project​​.

  4. Conversion and Code Updates: The .NET Upgrade Assistant will convert your project files to SDK-style projects, update target frameworks, set <UseMaui>true</UseMaui>, and handle NuGet package transitions:
    • Remove Xamarin.Forms and Xamarin.Essentials packages.
    • Replace Xamarin.CommunityToolkit with .NET MAUI Community Toolkit.
    • Update SkiaSharp packages for .NET MAUI compatibility.
    • Replace Xamarin.Forms and Xamarin.Essentials namespaces with Microsoft.Maui and Microsoft.Maui.Controls​​.

Remember, while the Upgrade Assistant does a lot, it might not cover everything. Manual adjustments and testing will be necessary to ensure a smooth transition. Keep the .NET MAUI documentation handy for reference and don’t hesitate to provide feedback to improve the tool further​​.

Watch Out for These Migration Speed Bumps

Migrating from Xamarin to .NET MAUI is a forward leap in app development, but it’s not without its hurdles. One of the common challenges is the absence of OpenTK on iOS, which means OpenGL is no longer available. For Xamarin.watchOS projects, it’s recommended to bundle Swift extensions with .NET for iOS apps.

Additionally, before upgrading your Xamarin native projects to .NET, ensure they are SDK-style projects and that dependencies are updated to .NET 7+. Also, while the .NET Upgrade Assistant can streamline the migration of multi-project Xamarin.Forms apps to .NET MAUI, be prepared to invest additional effort post-upgrade to address any nuances and ensure your app is fully functional in the new environment.

When transitioning from frameworks like MvvmLight or MvvmCross to the MVVM Toolkit, you’ll encounter several changes:

  1. ObservableObject: Replace MvvmLight’s ObservableObject with the MVVM Toolkit’s version, adjusting the using directives in your components accordingly.

  2. SetProperty Methods: The signature for methods like Set<T>(Expression, ref T, T) does not have a like-for-like replacement in the MVVM Toolkit. Instead, use SetProperty(ref T, T, string) which offers similar functionality with performance benefits.

  3. PropertyChanged Event: For raising property change notifications, switch from RaisePropertyChanged(string) to OnPropertyChanged(string) in the MVVM Toolkit. The new method infers the property name automatically, simplifying the code.

  4. VerifyPropertyName: The VerifyPropertyName(string) method does not have a replacement in the MVVM Toolkit due to the availability of the nameof keyword for verifying property existence.

  5. PropertyChangedHandler: There is no direct replacement for PropertyChangedHandler. Use OnPropertyChanged() to raise property change events instead.

  6. ViewModelBase Migration: For components using ViewModelBase, the MVVM Toolkit offers ObservableRecipient, which provides similar functionality.

  7. Namespace changes: Replace MvvmCross namespaces with their CommunityToolkit.Mvvm counterparts. For instance, change using MvvmCross.ViewModels; to using CommunityToolkit.Mvvm.ComponentModel; and using MvvmCross.Commands; to using CommunityToolkit.Mvvm.Input;. This change is necessary for ViewModel and Command implementations to align with CommunityToolkit.Mvvm’s structure.

  8. Navigation Changes: CommunityToolkit.Mvvm doesn’t include built-in navigation features like MvvmCross. You’ll need to implement a navigation service that works with the navigation patterns in .NET MAUI.

  9. Dependency Injection: whether you are using MVVMCross (with it’s own DI container), MVVMLight (with SimpleIoc), Prism (with Unity Container) or implementations like DryIoc or Autofac, evaluate if you should continue with it or switch to the built-in .NET DI framework.

Testing and quality checks are integral throughout this process. Rigorous testing will highlight any discrepancies that need your attention, ensuring that the final product maintains the high-quality standards users expect from a .NET MAUI app.

Additional Support

If you’re looking for additional expertise and support during your migration journey, Xablu specializes in the transition from Xamarin to .NET MAUI. We offer comprehensive services to assist with everything from assessing your existing codebase and guiding the migration process to optimizing performance for a successful adoption of .NET MAUI​​. Keep in mind that with Xamarin support ending on May 1, 2024, now is a critical time to embrace the transition to .NET MAUI to stay ahead in cross-platform development​​.

Here’s a list of links to these resources:

Please share your thoughts 😃

Curious how Xablu can help your organization ?