Good news - Visual Studio 2022 includes Xamarin support for iOS, iPadOS, macOS, and tvOS under Android 12 and Apple's latest Xcode 13 release, as well as the latest Xamarin.Forms version that supports them. Let's take a look at the latest Xamarin release, revisit Xamarin's support policy, and look ahead to .NET 6 and .NET MAUI in Q2 2022.
Visual Studio 2022
Visual Studio 2022 has many improvements and new experiences, and Xamarin.Forms applications will also get some improvements. XAML Live Preview is one of the most exciting features , it mirrors your running application in Visual Studio and allows adding layout guides and scaling for perfect pixel alignment. A live visual tree lets you see your UI hierarchy and locate XAML source code, and XAML hot reloading is constantly improving.
- Visual Studio 2022 Release Notes
- XAML Hot Reload
- XAML Live Preview
- XAML Live Visualization Tree
- Xamarin
- Known Issues
Xamarin supports latest mobile version
Over the past few months, Xamarin has released several Xamarin.Forms service releases, as well as beta and stable .NET bindings from Google and Apple. These sdk's are available in the new stable version of Visual Studio 2022 and the latest version of Visual Studio 2019 (Xcode 13.1 sdk support will be released in the next version of Visual Studio 2019)
- Visual Studio 2022(17.0) -
- Visual Studio 2022 for Mac(17.0) -
- Visual Studio 2019 (16.11.6) - download
- Visual Studio 2019 for Mac(8.10.12) -
Xamarin.Forms 5
Xamarin.Forms 5.0 Service Release 6 was released on October 18 with 145 fixes since its initial release. This includes support for Andriod 12 and iOS 15, which we will continue to release every 6 weeks. You can download build from any pull request and commit from GitHub and Azure Pipelines. You can also use the link below to view complete release notes . Update your application today with your favorite NuGet package manager so you can better upgrade to .NET MAUI.
Andriod 12
Google has released the latest stable version of Andriod 12, including a new Material You design language, updated widget designs, overall system performance improvements, and new features and APIs for camera, graphics and images, media, security and privacy, storage, and more . For a complete list of updates and documentation, visit the Android Developer Portal .
To support Andriod 12, we have upgraded from version 8 to OpenJDK 11 and updated Android Designer, SDK Manager and Device Manager for compatibility.
iOS 15, iPadOS 15, tvOS 15
Apple has released Xcode 13, which includes iOS 15, iPadOS 15, and tvOS 15. Apple also released Xcode 13.1, which adds support for macOS Monterey 12.
Xamarin Two-
With the changes to the .NET MAUI release schedule , and .NET 6 support for Android, iOS, and macOS, we would like to update you on Xamarin's support and servicing plans during this transition. Xamarin is governed by the Microsoft Modern Lifecycle , which states that the current Xamarin version is supported for two years after the initial release, or until the next updated stable release. .NET MAUI and related platforms will be included in .NET and .NET Core Support Policy , after all it is now a unified part of .NET.
This means that, starting with the latest version of Xamarin, you get two years of supported service releases, and you can expect support until November 2023. During this time you can migrate your existing projects to .NET 6 and we are working hard to provide you with a smooth process.
for the transition to .NET 6
In the second quarter of 2022, we will release a version that supports .NET Multiplatform Application Interface (MAUI), the next version of .NET that supports cross-platform, mobile and desktop applications. The first priority of this transition is to ensure that Xamarin applications can be upgraded to take advantage of the latest updates in .NET, C# and Visual Studio without requiring a rewrite. This means that Xamarin projects only need to move from .NET Framework to .NET 6 and you can go ahead and publish.
Let's first take a step-by-step look at what this means for any Xamarin application.
Step 1: .NET Upgrade Assistant
The .NET Upgrade Assistant is a .NET command line tool that converts your projects (csproj files) from Xamarin .NET Framework style to current SDK style projects (commonly used by all other .NET project types). As you'll recall, this shift brings Xamarin together with .NET, so no matter what application we're building, we can all share the same technology and skills.
Step 2: Update dependencies
After converting your project file format, the tool will evaluate your project dependencies and report any incompatibilities so you can re-evaluate. If you are using controls from component vendors such as DevExpress, Infragistics, Steema, Syncfusion, Telerik or others, they may already be available. Every roadmap plan and availability can be checked.
The Xamarin Community Toolkit provides two options for upgrading to .NET 6. The first is a 1-to-1 compatible version of the .NET 6 compatible toolbox, and the second option is a pure .NET 6 version that takes advantage of all the architectural improvements in .NET, albeit probably not quite there yet 1:1 equivalent of the Xamarin Community Toolkit.
Xamarin.Essentials is now part of .NET 6 and .NET MAUI, so you can get it without any additional NuGet dependencies.
If your project is Xamarin.Android or Xamarin.iOS, then you are most likely done with the migration after completing the steps above, just compile and test your app.
Step 3 (optional): Xamarin.Forms to .NET MAUI
.NET MAUI uses the same control naming, layout naming, navigation mode, and XAML features that your application uses in Xamarin.Forms. This means it will work as is. So what has changed?
.NET MAUI uses the namespace "Microsoft.Maui" instead of "Xamarin.Forms". The .NET Upgrade Assistant will make this change for you in your XAML and C# files. If you didn't update NuGet for Xamarin.Forms in the previous step, you now need to address these issues.
What other differences do you encounter?
- Applications vs. Windows – Xamarin.Forms applications are single-window, while .NET MAUI applications can be multi-window. This means that the root view of the application has been radically upgraded. We've preserved the styles of App.cs (and App.xaml.cs), so your app can continue to work as-is.
- Custom Renderers - .NET MAUI no longer requires them in the new "processor" architecture, but we provide a compatibility method for you to register so you can continue to use them. For future needs, we recommend learning the handler pattern to customize the appearance of platform controls. For example, let's say you have a custom renderer for android (CustomEntry in the library) (CustomEntryRenderer in the android project), you want to tell .NET MAUI where to find this renderer and how to use this renderer instead of the new handler , please open MauiProgram.cs in the project root directory, where we define the application generator:
appBuilder
.UseMauiApp<App>()
.ConfigureMauiHandlers(handlers =>
{
#if __ANDROID__
handlers.AddCompatibilityRenderer(typeof(CustomEntry), typeof(Droid.Renderers.CustomEntryRenderer));
#endif
});
Do this for each renderer using a conditional compilation identifier such as __ANDROID__.
- Effects - Just like custom renderers, you can register them in the app builder.
appBuilder
.UseMauiApp<App>()
.ConfigureEffects(effects =>
{
effects.Add<FocusRoutingEffect, FocusPlatformEffect>();
});
Open the project in Visual Studio 2022 and start building. You may encounter some type changes or incompatibilities. Fix these issues and soon you will have completed the transition to .NET 6. Depending on the complexity of the application and the availability of .NET 6 compatible dependencies, this can take anywhere from a few hours to a few days of work.
To try the migration now, try the .NET Upgrade Assistant and provide feedback so we can continue to improve the assistant between now and the general release.
For other examples of migrating projects from Xamarin.Forms to .NET MAUI, check out Javier Suarez Ruiz's repository Xamarin.Forms to .NET MAUI ).
summary
.NET MAUI Preview 10 is now available in the Visual Studio 2022 Preview Channel and Xamarin.Forms 5.0 is available. Both support the latest platform version. If your project takes more than 4 months to develop, or everything you need is ready in .NET MAUI, then we recommend starting there.
Get started today with the following resources:
• Visual Studio 2022 (17.0) – download
• Visual Studio 2022 for Mac (17.0) –
• Visual Studio 2022 Preview (17.1) –
• Announces .NET MAUI Preview 10
• .NET MAUI documentation
• Visual studio 2022
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。