Up to now we’ve installed .NET MAUI on Windows and got the Android emulator running. .NET MAUI’s brilliance is that it is Multi-platform. That doesn’t mean just Windows and Android. We can target Mac Catalyst and iOS too. Let’s look at how that is setup.
First, download the Visual Studio 2022 for Mac Preview. Find it in your Downloads folder and run it. Once it starts up make sure to check the Core and CrossPlatform options.
Click the Install
button and wait for it to download and install. Next select the shortcuts that you want to utilize. I’m going all in on the Mac and am going to learn the Visual Studio for Mac keybindings. Although I’ll probably switch in the Preferences later.
You may be asked to log in with your Microsoft Account. After that you’ll find this screen.
Now let’s create a quick application to show that it works. Click the + New
button and the template selection screen will open up.
Select Multiplatform and App from the left then select .NET MAUI App on the right. Then click the Continue
button. Give the project a name like “MyFirstMAUIApp”. Make sure the location is okay and click the Create
button. We’ll use git in the future when we expand on the To-Do app we started on Windows. If all went well you should see the code as below.
Click the play button in the top left corner and the app will spin up. If you get an error that the Apple SDK cannot be found go into Preferences from the Visual Studio menu select Apple from the SDK Locations option and change the Apple SDK Location to /Applications/Xcode.app
and restart Visual Studio 2022 for Mac Preview. (You do have XCode installed right?)
You can change the device by clicking on where it says My Mac
next to Debug
(the Debug next to the Play button) and select an iPhone or iPad device to run it on. Here it is running on an iPhone 12 simulator.
You are all set to continue development with .NET MAUI. Let me know how it goes for you.