Fall 2022 Updates for Xamarin, Hello iOS 16 and Android 13
Today we are happy to announce that Xamarin support is now available for iOS 16 in Visual Studio 17.3.5 on Windows and 17.3.6 on Mac. iOS 16 now joins Android 13 (API 33) in Xamarin to support the latest mobile versions on both platforms. iOS 16 is part of the larger Xcode 14 release from Apple which will soon also add new versions of iPadOS, tvOS, macOS, and Mac Catalyst. Apple has not yet released those updates, so your applications will continue to work using the existing versions of those SDKs. To get started today, install these versions of Visual Studio along with Xcode 14 on your Mac.
If you are using .NET 6 or the newly released .NET 7 release candidate, we advise you to keep Xcode 13 and Xcode 14 installed side-by-side. In a near future release, we will ship Xcode 14 support for .NET 6 and 7 at which time everything will work with Xcode 14.
Xamarin Support Update
During the recent .NET Conf Focus on MAUI event in early August, we shared an updated roadmap that details the support transition from Xamarin to .NET. We are happy to be able to provide you with seamless support during your transition from Xamarin to .NET MAUI through May 1, 2024. We are also smoothing the technical transition for you. Due to the external dependencies on Apple and Google for Xamarin and .NET MAUI, the support story is a bit more nuanced than for the .NET SDK and runtime itself. Let’s break down the timeline and I’ll show you the path ahead for your projects.
Xamarin SDKs will be supported through May 1, 2024, with the final platform versions being Android 13 and iOS 16. All project code can be upgraded to .NET 6 and beyond without rewriting your apps.
About Xamarin.Android and Xamarin.iOS
These mobile SDKs are the foundation of .NET for mobile! In .NET 6 we unified them with the rest of .NET on the same base class library (BCL) including C# types (iOS had some overlap) and running on the same runtime. It’s all there for you in .NET 6 and will continue as (part of) .NET!
We have shipped Android 13 and iOS 16. These are the final platform versions we will support for Xamarin. Subsequent versions of Android and iOS will be released in .NET. Before then, we highly recommend you complete your transition.
Consider that Apple historically releases new major versions in September, and the Apple App Store immediately requires new apps to use the latest version, and by April of the following year requires all apps to be built with the latest version. Google is a bit more generous with its policy, but it also has an end.
When it comes to mobile apps especially, make sure you quickly adopt the latest versions in order to stay compliant, performant, and secure.
Upgrading to .NET 6: Android and iOS
In order to upgrade your Xamarin.Android and Xamarin.iOS projects to .NET you will first update to the SDK Style project system (i.e. update your csproj) and then update your dependencies to .NET 6 compatible versions. For most applications, that’s the beginning and the end of the journey – compile and test your apps. You don’t need to change namespaces or rewrite these apps.
- Update your csproj to SDK Style
- Upgrade or replace incompatible dependencies with .NET 6 versions
- Compile and test your app
Xamarin.Forms has been renamed to .NET MAUI and gives you all the same code sharing and productivity you’ve enjoyed for years, plus new desktop platforms, Blazor components, and simpler coding patterns. Your Xamarin.Forms projects also upgrade to .NET MAUI without rewriting them! Here are a few additional considerations and things to be aware of as you plan.
- You do not need to rewrite your code, even custom renderers
- Moving to single project is optional
- .NET Upgrade Assistant is a work-in-progress and optional
- Xamarin.Essentials is now part of .NET MAUI
- Visual Studio 2022 17.3 on Windows includes .NET MAUI, and .NET MAUI tooling is in preview 17.4 on macOS
Upgrading to .NET 6: Xamarin.Forms
Very little has changed in .NET 6 for Android and iOS since they are .NET bindings of the SDKs shipped by Google and Apple. Xamarin.Forms is where we have added on productivity, patterns, layouts, and controls to enhance your cross-platform mobile experiences. .NET MAUI is Xamarin.Forms renamed, and improves upon Xamarin.Forms for performance, extensibility of layouts and controls, consistency and reliability, and exanded reach for your apps to desktop. All this and much more has been added to your development experience in .NET MAUI, so what does it take to migrate your project?
- Update your csproj to SDK Style*
- Update Xamarin.Forms namespaces in C# and XAML* – Documentation
- Update code for major version breaking changes* – Documentation
- Upgrade or replace incompatible dependencies with .NET 6 versions* – Documentation
- Compile and test your app
- Touch-up layout and styling
*Our migration guide documents how .NET Upgrade Assistant can help with these items, and how you can do them manually.
Xamarin developers have also been able to use Xamarin SDKs to target more than just mobile, sometimes because they “just work” when we ship the mobile SDKs and tooling. What of those continue to be available to you .NET?
- Apple: App Extensions, CarPlay, tvOS
- Google: Android Auto, Android Wear
Each release of .NET MAUI (including the platform SDK dependencies for Android, iOS, etc.) will follow the same support policy and shipping schedule as defined on the official support policy page.
Each release of .NET MAUI is scheduled to coincide with .NET SDK on the annual cadence with monthly servicing opportunities. Support for .NET MAUI will always end 6 months after the next release. For more details, refer to the the official support policy.
We are often asked “how long should it take to upgrade an application to .NET 6”, and (as usual) the answer is “it depends”. To get most projects setup, building, and debugging can take a day or less. The usual tasks that slow this process down are .NET 6 incompatible 3rd party dependencies that you will either upgrade, replace, or remove.
We are excited for the future of .NET for building client applications! Please let us know how you get along with your upgrades from Xamarin, and how we can improve your experience by emailing me email@example.com or by opening an issue for us on GitHub.
You do not need to rewrite your code, even custom renderers This is a fairly inaccurate statement and how inaccurate will depend on your Xamarin.Forms project.
You do not need to rewrite your code, even custom renderers This statement is partially true. I have a Xamarin.Forms app with 5 custom renderers. The MAUI version was only able to keep 3. I was able to remove one renderer by re-writing the code to do the same thing in a different way. I still need to find a solution to the remaining renderer, which was crashing my app in the MAUI version.
Application startup has completely changed.
Project structure has completely changed. Going from a shared project and one project per platform to a single project. (I tried to keep the “shared” code in a separate project and ran into issues. This means you cannot just branch a repository and make changes to the MAUI branch.)
If you’ve implemented dependency injection, this has changed, since it is now built in, which is a good thing.
If you use a 3rd party library like Prism, then your entire app startup will change, as will dependency injection. Also navigation does NOT work the same way as Prism for Xamarin.Forms. I was using Prism. I have abandoned it for the MAUI version.
If you are trying to create a MAUI version that looks the same and is as close to the Xamarin.Forms version as possible (i.e. pixel by pixel match), it will be painful or outright impossible. Documentation on migrating from Xamarin.Forms to MAUI is missing important details:
– changes to default values (such as default button colors) and other color defaults.
– default spacing for layouts such as Grid and StackLayout (this may be documented and was mentioned in David’s blog months ago.)
– default font has changed. This is important for matching spacing of text.
– default background color for pages has changed.
Why is there not a theme, skin or set of default styles that can be applied to a MAUI app to make it match, as much as possible, how a Xamarin.Forms app looks? I’ve asked, the answer is there isn’t such a thing. This SHOULD be an option in the MAUI template!
There are also bugs:
– SwipeItemView does not work https://github.com/dotnet/maui/issues/10065
– Shell always reuses pages https://github.com/dotnet/maui/issues/10164
– I’ve run into a bug where padding in a style does NOT get applied with certain combinations of controls. I believe this is logged, but do not have the bug number.
– Some certificates that work fine in Xamarin.Forms apps (verified on iOS/Android) and all major browsers on a PC, do NOT work on MAUI Android apps. I think the error is something like “trust anchor for certification path not found.”
– If you use data binding in xaml to set colors and your variable returns a string with an RGB value like “#aabbcc”, this will work fine in Xamarin.Forms, but not work in MAUI. You need to change your code to either return a Color value or use a converter to return a color.
– Disabled controls (or at least the Button control) do NOT look disabled if you set IsEnabled = false and you change the button color. Disabled buttons look disabled if you use default colors. This is different than Xamarin.Forms
There should also be a list of properties from Xamarin.Forms that are obsolete in MAUI and what the alternative should be for someone migrating.
I would upgrade my apps to NET6/7 (I don’t use X.Forms, only Xamarin.Native), but essential dependencies are missing. Especially from MS 🙂 Like Azure notification hub or App center. On Android it is possible to use xamarin versions, but not on iOS.