Creating Your First Application For MacOS Using .NET MAUI

.NET MAUI was released in May 2022, offering the possibility to create multi-platform applications using C# and .NET with the same base code. .NET MAUI supports Android, iOS, macOS, Tizen and Windows. In this article, we will analyze how to begin with .NET MAUI for macOS.

First, we must clarify an important aspect about how .NET MAUI works with macOS. App for .NET MAUI works with Mac Catalyst. This a solution created by Apple that allows us to run iOS apps in a desktop platform. It works using UIKit to compile in macOS and can be extended using AppKit.

There are some requirements to create projects with .NET MAUI in macOs. Let's check them out:

  • xCode
  • .NET 6.0.300
  • macOS 10.15 or later, with Mac Catalyst
  • Visual Studio for Mac Preview 17.x (Optional if you want to use this IDE)

After installing all these requirements, you can install .NET MAUI and create a demo app.

First, let's install the workload using the following command:

sudo dotnet workload install maui --source https://api.nuget.org/v3/index.json

After that, you can use the command dotnet new maui to create a new a new .NET MAUI Ap, you can add a custom name. For example:

dotnet new maui -n "MyMauiApp"

To execute the application, you can use the following command:

dotnet build -t:Run -f net6.0-maccatalyst

Use the previous command always you need to execute the app and check your changes.

If you want to use Visual Studio for Mac, you can select the new template in the multiplatform section and then complete:

Finally, if your app is ready and you want to create an app file (binary file) to share your app with other, you need to execute the following command:

dotnet build -f:net6.0-maccatalyst -c:Release

To create the .pkg file (an installer binary) you can execute the following command:

dotnet build -f:net6.0-maccatalyst -c:Release /p:CreatePackage=true


Similar Articles