Build together, debug together. Join the community on Discord.→

Hello macOS!

Developer productivity and code reuse is at the heart of Uno Platform mission. Today we are adding macOS support preview and we are one step closer to achieving #WinUIEverywhere mission, enabling WinUI and your C# and XAML code to run on Windows, iOS, Android, Web, and now macOS.

macOS support was one of the top requested Uno Platform feature in surveys we did. We are glad to deliver on that key ask and to continue to develop it in the open together with you.

Today, when you create a new Uno Platform solution a new head project for macOS will automatically be created for you.

Windows Calculator on macOS

Previously, as a proof of concept for the level of code reusability you can achieve across mobile and the web, we had ported the open source Windows Calculator to Android, iOS and the Web, and published it as the Uno Calculator. Today, as a showcase of macOS support published in the macOS App Store, we are extending that example to also include macOS.

How to enable your existing Uno app to run on macOS

If you already have an Uno application and you want to add support for macOS, you’ll need to update the Uno.UI NuGet packages to the version 2.4 or later.
In order to create a macOS head, we can use the Uno dotnet new Templates to create a temporary solution that will include the macOS project.

On your Mac,

dotnet new -i Uno.ProjectTemplates.Dotnet::2.4

– Then create a temporary app:

dotnet new unoapp -o MyApp -ios=false -android=false -uwp=false

where MyApp is the name of the application that will be created. It’s best if the name matches the one your existing app already uses.

– Move the MyApp.macOS project next to your existing project heads
– In Visual Studio for mac, the created project can then be added to your current solution

Once this is done you will be able to compile and run the macOS project of your app.

How to get started with Uno Platform for newcomers

To create a new application with Uno in Visual Studio for Mac:

dotnet new -i Uno.ProjectTemplates.Dotnet::2.4
dotnet new unoapp -n MyUnoApp

To build for each platform:

Note that at present time, UWP development is not supported on macOS, and Uno Platform WebAssembly is supported in VS Code.

MacOS Implementation Details

The implementation of the macOS support is Uno is heavily based on the iOS support. The reason for this is UIKit for iOS being very close to AppKit on macOS. This allowed us to reuse large portions of the code from iOS and adjust to fit macOS’s behavior.

Yet, there are some very subtle differences in the implementation though, where methods such as UIKit.SizeThatFits() or UIKit.SetNeedsLayout() are either absent or behaving very differently. That may be why you’ll notice parts that need so fit and finish and we encourage you to open issues on our GitHub repo.

You may ask why we did not choose to go the Catalyst route, and you’d be right. The main reason is the lack of support for Catalyst from Xamarin, and if you want to chime in this issue if this is of interest to you.

At this time, and contrary to what’s available for iOS, debugging and deploying a macOS app must be done through Visual Studio for mac, while only building is possible in Visual Studio 2019 for Windows. This feature is missing from the Xamarin tooling, and if you want that support to be added, you can vote or submit comments on this issue on the Visual Studio Community site.

Next Steps

We’d really appreciate if you give Uno Platform a try, either as a newcomer via official Get Started tutorial or if you updated your existing projects and logged any issues you might have faced.

Also, our huge thanks go to community contributor Martin Zikmund who was fundamental for getting the macOS support. THANK YOU MARTIN!

Andres Pineda, on behalf of Uno Platform Team

 

Uno Platform 5.2 LIVE Webinar – Today at 3 PM EST – Watch