.NET MAUI on macOS
Welcome to the macOS platform guide for .NET Multi‑Platform App UI (MAUI). This tutorial walks you through setting up a development environment on macOS, creating a MAUI app, leveraging macOS‑specific APIs, and publishing your app to the Mac App Store.
Setup macOS Development
- Install .NET SDK 8.0+.
- Install Visual Studio for Mac with the “.NET MAUI” workload.
- Ensure Xcode is installed (latest stable version) and command‑line tools are active:
xcode-select --install
- Verify the MAUI workload:
dotnet workload list
Project Structure
A typical MAUI solution includes the shared project and platform folders:
MyMauiApp/
├─ MyMauiApp.csproj
├─ Platforms/
│ ├─ MacCatalyst/
│ │ ├─ AppDelegate.cs
│ │ └─ Info.plist
│ ├─ iOS/
│ └─ Android/
├─ Resources/
│ ├─ Images/
│ └─ Fonts/
└─ MainPage.xaml
macOS‑specific Features
Using NSWindow
You can customize the native NSWindow
from MAUI:
using Microsoft.Maui.Platform;
using AppKit;
public partial class App : Application
{
protected override Window CreateWindow(IActivationState activationState)
{
var window = base.CreateWindow(activationState);
var native = window.Handler.PlatformView as NSWindow;
native.Title = "My MAUI macOS App";
native.HasShadow = true;
return window;
}
}
Menu Bar Integration
Add a macOS menu bar item:
public static void AddMenu()
{
var mainMenu = NSApplication.SharedApplication.MainMenu;
var appMenu = new NSMenuItem { Title = "MyApp" };
var submenu = new NSMenu();
submenu.AddItem(new NSMenuItem("About MyApp", () => ShowAbout()));
submenu.AddItem(NSMenuItem.SeparatorItem);
submenu.AddItem(new NSMenuItem("Quit MyApp", "q", () => NSApplication.SharedApplication.Terminate(null)));
appMenu.Submenu = submenu;
mainMenu.AddItem(appMenu);
}
Packaging & Deployment
- Set the bundle identifier in
Info.plist
. - Configure signing in Xcode or via Visual Studio signing settings.
- Publish:
dotnet publish -f net8.0-maccatalyst -c Release /p:RuntimeIdentifier=osx-arm64
- Submit the generated
.app
bundle to the Mac App Store using Transporter.
Troubleshooting
- Missing Xcode SDK: Run
xcode-select --switch /Applications/Xcode.app
. - App fails to launch: Check the console for sandbox violations and ensure all entitlements are configured.
- Code signing errors: Verify the team ID and provisioning profile in Visual Studio.
Next steps: explore Android, iOS, and Windows platform guides.