.NET MAUI Preview 4 on Mac

Visual Studio for Mac is not supporting .NET preview 4 yet. 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

Review of Apple Macbook Pro M1

It is now about two weeks since I got my Apple Macbook Pro M1 delivered. It is the one with 16 GB of RAM and 2 TB SSD. Delivery time was quite long, I ordered it at the beginning of December. But now when I have used it as my primary machine for a while it is time for a review.

I primarily use it for .NET development including app development using Xamarin and backend development using .NET Core 3 and .NET 5. I also, do some development using Blazor from time to time.

Overall

To overall impression is that it is a really fast machine. macOS and applications that are optimized for the machine are really fast. Applications that not are optimized are faster or at least not slower than on my old MacBook Pro from 2017.

What is great is that it never became hot, not so far, it can be a little bit warm, but I have never heard the fan. On my old MacBook, the fan sounded like a jet plane.

As always with a Macbook it is very solid. I like that they have switched back to the old keyboard. The only downside is that it only has two thunderbolt/USB-ports. So you probably need a USB-hub. I have a display connected with USB-C that has USB-ports and it also powers the computer.

Xamarin development

As we could expect, iOS development is not an issue, because Apple has of course optimized XCode for the new M1 Macs. And Visual Studio for Mac runs good with Rosetta 2, But what about Android? The development worked well, but to run my app on an emulator I had to go and download a preview version of the emulator for the new Macs. But the emulator works really well and it is really fast. But right now (preview 3) you cannot run Chrome on it. You can download it from here. https://github.com/google/android-emulator-m1-preview

Backend development

To do backend development with .NET Core 3+ and .NET I had to install the beta of Big Sur 11.2. Before that, it crashed every time that I tried to debug an application. But with the beta, it is working like a charm.

For Visual Studio Code there is an insider build that is compiled for ARM. That version is really good, it is much faster than the "old" Visual Studio Code.

Docker

Docker has a preview for M1, https://docs.docker.com/docker-for-mac/apple-m1/. It works great, there are some problems with images that not are for ARM. I tried with an SQL Server 2019 image for example and that one did not work. https://github.com/docker/for-mac/issues/5170#issuecomment-767803717. But a colleague found an image that I can use for SQL-server that had enough features for me, mcr.microsoft.com/azure-sql-edge. I also run a container for MongoDB without any issues.

Streaming and media

I have tried Streamlabs OBS and there are no problems running it with Rosetta 2. It feels more smooth compared to running it on my old Mac.

For editing videos, I have tried iMovie, an app that Apple has optimized for M1. It works really great, I imported and 6-hour long video with a size of 13 GB and it worked like I imported just a short video.

I also have tried Adobe Photoshop without any issues.

Other applications

Microsoft Office including Word, Excel, Outlook, and Teams, etc. runs fine. But I could not get OneDrive sync working. The same with Google Drive sync.

Running Windows

You cannot run Bootcamp on the M1 Macs. But Parallels Desktop has a technical preview, https://www.parallels.com/blogs/parallels-desktop-apple-silicon-mac/, that are able to run Windows ARM. The problem is that Windows ARM images can be hard to find. But after I asked on Twitter I got an answer that there are insider builds that is available for download. So I did and Windows runs much better on Parallels now than compared with the x64 version on my old Macbook. I also was able to run Visual Studio (x86) on it and it works ok, it is as good as running it on Parallels on my old Macbook.

Summary

MacBook Pro M1 is a really good and fast computer, there are some small issues, but if you should buy a new Mac now, I recommend you to buy an M1, Intel Mac feels old!