This exciting new release is all about enabling development on macOS and making apps for macOS!
We've been working on this for a while now, and with the help of contributors (thanks @MartinZikmund!), we're now announcing the preview of Uno's macOS support.
To validate that our macOS support is taking shape, we ported over the Uno Calculator over, and it's now available on the mac App Store.
There are lots to do to get to the full potential of macOS through Uno's abstractions, yet it will allow you to start developing for macOS.
To create a new application with Uno in Visual Studio for mac:
-
Open a terminal
-
Type the following to install the Uno templates:
dotnet new -i Uno.ProjectTemplates.Dotnet::2.4
-
Type the following to create a new project:
dotnet new unoapp -n MyUnoApp
-
Open the project in Visual Studio
To build for each platform:
-
For macOS:
- Right click on the macOS project, then Set as startup
- If “My Mac” is not selected in the top bar, make sure to select “Debug | iPhone Simulator” in the selector
-
For iOS:
- Right click on the iOS project, then Set as startup
- In the configuration selector, instead of Debug, select Debug | iPhoneSimulator
-
For Android:
- Right click on the Android project, then Set as startup
- If your android device or simulator does not appear in the list, use the Debug configuration.
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 on this issue on the Visual Studio Community site.
Features
Bug Fixes
- dotnet_new: Adjust default active projects in VS for mac (ec2de29)
- dotnet_new: Fix project guids duplicates causing issues in VS4mac (1ef6b78)
- macos: Missing mac platform for Uno.UI.RemoteControl (1d57cc2)
- xbind: Possible invalid type cast in two-way mode (b952235)
- xbind: Fix static member access in DataTemplate (d3c70c3)