Daniel Hindrikes
Developer and architect with focus on mobile- and cloud solutions!
Developer and architect with focus on mobile- and cloud solutions!
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.
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.
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.
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
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
To run it on an Android emulator, just start the emulator before you start the app.
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