.NET MAUI Preview on Mac

Visual Studio for Mac is not supporting the current .NET preview. But that doesn't mean that you cannot start to play with MAUI. But you have to use the terminal and for example Visual Studio Code.

Install .NET MAUI

If you do not have installed the preview yet, I recommend you to do that with the Maui Check Tool, https://github.com/Redth/dotnet-maui-check. That will guide you through the process and make sure that you have everything you need install.

Create a project

To create a new project, just use the dotnet new command as with all .NET Core/.NET 5 projects.

dotnet new maui -n MyFirstMauiApp

or this for a MAUI Blazor (Hybrid app) project.

dotnet new maui-blazor -n MyFirstMauiApp

If you want to take a look at a sample app, you may have seen the Weather Twenty One app by David Ortinau. That project is open-source and a good app to sample to start with if you want to explore MAUI, https://github.com/davidortinau/WeatherTwentyOne.

Run a .NET MAUI app

When you want to run an MAUI app from a command, you need to specify what framework you want to use, for example, .NET 6 iOS.

# iOS
dotnet build {YourProjectName} -t:Run -f net6.0-ios
# MacOS
dotnet build {YourProjectName} -t:Run -f net6.0-maccatalyst
# Android
dotnet build {YourProjectName} -t:Run -f net6.0-android
Weather Twenty One app running on Mac Catalyst and iOS simulator

Weather Twenty One app running on Mac Catalyst and iOS simulator

Run on a specific iOS simulator

When you started the iOS project, it probary started on an iPad simulator. If you want to use another simulator you need to set the UDID of the simulator in the command like this:

dotnet build {YourProjectName} -t:Run -f net6.0-ios /p:_DeviceName=:v2:udid={DeviceUDID}

To get all UDID:s run the following command:

xcrun simctl list

Run on an Android emulator

To run it on an Android emulator, just start the emulator before you start the app.

Weather Twenty One app running on Android emulator

Weather Twenty One app running on Android emulator

More resources

Official MAUI Sample repo - https://github.com/dotnet/maui-samples
MAUI source code - https://github.com/dotnet/maui
Announcing .NET MAUI Preview 4 - https://devblogs.microsoft.com/dotnet/announcing-net-maui-preview-4

4 thoughts on “.NET MAUI Preview on Mac

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.