Microsoft.Maui.Platforms.MacOS.BlazorWebView
0.1.0-preview.16.26575.2
Prefix Reserved
dotnet add package Microsoft.Maui.Platforms.MacOS.BlazorWebView --version 0.1.0-preview.16.26575.2
NuGet\Install-Package Microsoft.Maui.Platforms.MacOS.BlazorWebView -Version 0.1.0-preview.16.26575.2
<PackageReference Include="Microsoft.Maui.Platforms.MacOS.BlazorWebView" Version="0.1.0-preview.16.26575.2" />
<PackageVersion Include="Microsoft.Maui.Platforms.MacOS.BlazorWebView" Version="0.1.0-preview.16.26575.2" />
<PackageReference Include="Microsoft.Maui.Platforms.MacOS.BlazorWebView" />
paket add Microsoft.Maui.Platforms.MacOS.BlazorWebView --version 0.1.0-preview.16.26575.2
#r "nuget: Microsoft.Maui.Platforms.MacOS.BlazorWebView, 0.1.0-preview.16.26575.2"
#:package Microsoft.Maui.Platforms.MacOS.BlazorWebView@0.1.0-preview.16.26575.2
#addin nuget:?package=Microsoft.Maui.Platforms.MacOS.BlazorWebView&version=0.1.0-preview.16.26575.2&prerelease
#tool nuget:?package=Microsoft.Maui.Platforms.MacOS.BlazorWebView&version=0.1.0-preview.16.26575.2&prerelease
.NET MAUI for macOS (AppKit)
A native .NET MAUI backend for macOS using AppKit — not Mac Catalyst.
This backend lets MAUI applications run as true native macOS apps that use AppKit controls
(NSWindow, NSButton, NSScrollView, etc.) and follow standard macOS UI conventions
(menu bar, toolbar, sidebar flyout, native dialogs, etc.).
Dialog registration supports both the nested MAUI 10.0.41-10.0.60 subscription interface and the top-level interface in 10.0.70+. An unrecognized contract fails during registration instead of leaving alert, prompt, or action-sheet tasks pending.
Inspiration: Originally based on the shinyorg/mauiplatforms project. The Xamarin.Forms
Xamarin.Forms.Platform.MacOSbackend is also a useful historical reference for AppKit control mappings, although this project uses MAUI's modern handler architecture rather than the legacy renderer model.
Packages
| Package | Description |
|---|---|
Microsoft.Maui.Platforms.MacOS |
Core handlers, hosting, platform services |
Microsoft.Maui.Platforms.MacOS.Essentials |
MAUI Essentials implementations (clipboard, preferences, sensors, …) |
Microsoft.Maui.Platforms.MacOS.BlazorWebView |
Blazor Hybrid (BlazorWebView) support |
Shell navigation
Shell displays native segmented tabs for a TabBar (including a single tab) and for
FlyoutItems with multiple visible sections. The strip scrolls horizontally when
the tabs do not fit a narrow window. Section titles, enabled/visible state, collection
changes and selection update the strip without creating inactive pages.
Shell.TabBarIsVisible on the displayed page hides the strip.
Portable presentation tests run with
dotnet test platforms/MacOS/tests/MacOS.Tests/MacOS.Tests.csproj.
The shared MacOS.RuntimeTests host runs the shell-tabs scenario in an isolated
real AppKit process. Its native-runtime CI matrix row uploads screenshots, native
attachment traces and exact results as appkit-runtime-shell-tabs-default.
Run it through tests/MacOS.RuntimeTests/run.py --scenario shell-tabs --evidence <new-directory>
on macOS. The identical fixture checks a pinned two-file production overlay from
b0767ac6 for exactly three mounts per native click, then the current source for one.
The original 9206e7c missing-tabs proof remains historical, not this overlay's baseline.
The scenario also checks that the selected tab and displayed native page agree
after programmatic selection, hiding/removing the active section, and handler
rebinding, and that queued work is ignored after disconnect.
Native tab clicks use the same queued section refresh as programmatic selection.
The harness counts native attachments across recreated handlers to verify that
new and cached pages are displayed once per click, and checks narrow tabs and
explicit wide-sidebar presentation with titles and system icons.
Same-page refreshes retain valid native views while updating layout and chrome;
the native tests also cover remounts, handler/context replacement, and navigation
to a different destination during lazy page creation.
The scenario requires exactly 63 assertions; lower section navigation requires 59.
Wide/narrow checks explicitly select Locked at 1000 DIP and Disabled at 480 DIP,
not an automatic resize policy. Native sidebar title/icon/bounds checks are not
pixel proof: CacheDisplay omits the vibrancy/sidebar region.
Compilation and portable tests alone do not establish native rendering.
Shell section navigation
Shell observes section and content selection changes, including GoToAsync and
programmatic CurrentItem updates. The selected lazy page is created and hosted
without requiring a manual handler refresh; unselected templates remain lazy.
The shared MacOS.RuntimeTests host's shell-sections scenario exercises the
pre-fix Shell handlers and the current code through full MAUI/AppKit startup.
The native-runtime CI matrix uploads screenshots, navigation state and all 59
assertions as appkit-runtime-shell-sections-default. See the
shared runner for local macOS usage.
Prerequisites
- .NET SDK
11.0.100 - GA rollback manifest
eng/workloads/dotnet11-ga.jsonwith themacosworkload (27.2.11039) - macOS 14 (Sonoma) or later
- Xcode 27.2 for native build and runtime validation
- Xcode command line tools (
sips/iconutilare used by the icon build target)
The packages include both net10.0-macos (MAUI 10.0.110 by default) and
net11.0-macos (MAUI 11.0.10). Native application validation requires the Xcode
version pinned by each Apple pack: Xcode 27.2 for both the net10 servicing pack
(27.2.10000) and the net11 pack (27.2.11039). Install the net10 lane with
dotnet workload install macos maui --from-rollback-file eng/workloads/dotnet11-ga-macos-net10.json.
Switch back to eng/workloads/dotnet11-ga.json for net11 builds. The root SDK stays
at .NET 11; the compatibility manifest selects the released .NET 10 Apple pack.
A successful
library build is not a native application or resource-bundle pass.
Source-based net10 AppKit heads must align their direct MAUI references with
$(MacOSMaui10Version) rather than the repository-wide 10.0.41 baseline. The
AppKit samples import platforms/MacOS/MacOS.Versions.props, which keeps that
override scoped to AppKit consumers.
On .NET 11, AppKit uses public platform contracts for dialogs, gesture lifecycle,
assembly-aware font registration, view screenshots, and standard BlazorWebView
hosting. Essentials static facades use the application's DI provider; .NET 10
retains its reflection compatibility path. The existing AppKit screenshot
overload, raw asset logical names and filename defaults, and native .icns
packaging remain available. .NET 11 images and fonts use their processed
outputs; .NET 10 retains source image packaging and its static web asset bridge.
Both generations track native resource outputs for stale-file removal, normalize
Unicode logical paths, and reject resource-name collisions. Referenced-library
resources retain Apple's library-resource packaging.
Embedded fonts resolve an exact manifest path before a unique basename fallback;
ambiguous matches fail explicitly instead of depending on manifest ordering.
Blazor root-component replacements and clears are serialized through the same
managed reconciler used by GTK. The shared regression tests hold asynchronous
adds/removals open and verify selector reuse, no duplicate operations, and recovery
after a renderer failure. They do not prove native WebKit behavior.
builder.AddMacOSBlazorWebView() registers the required Blazor services on both
frameworks; native JavaScript messages are dispatched on the AppKit main thread.
The AppKit workflow accepts pull requests targeting main or the GTK stack branch,
redth-maui-net11-gtk. Portable contracts run independently of native build jobs;
native and package-consumer jobs retain Xcode validation. .NET 11 jobs use the
hosted xcode-27 image
with Xcode 27.2 explicitly selected. .NET 10 uses the same image and Xcode with
the AppKit-specific servicing rollback manifest. The sample, every non-camera
native scenario, DevFlow integration, and package-only resource acceptance run
for both framework generations.
Camera validation is opt-in on a camera-equipped self-hosted runner
(MAUI_APPKIT_CAMERA_TESTS=1).
Run package-only resource acceptance with
pwsh eng/smoke-tests/community-resource-acceptance.ps1 -Backend appkit -AppKitTargetFramework net10.0-macos -KeepArtifacts
(or net11.0-macos) after selecting the corresponding workload manifest.
Build the platform demo with
dotnet build platforms/MacOS/samples/MacOS.Sample/MacOS.Sample.csproj -f net10.0-macos
or -f net11.0-macos.
Quick start
Option 1: Use the template (recommended)
# Install the template
dotnet new install Microsoft.Maui.Platforms.MacOS.Templates --prerelease
# Create a new macOS MAUI app
dotnet new maui-macos -n MyApp.MacOS
cd MyApp.MacOS
dotnet run
Option 2: Add to an existing project manually
1. Project file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net11.0-macos</TargetFramework>
<OutputType>Exe</OutputType>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<SupportedOSPlatformVersion>14.0</SupportedOSPlatformVersion>
<ApplicationTitle>My macOS App</ApplicationTitle>
<ApplicationId>com.example.myapp</ApplicationId>
<ApplicationManifest>Info.plist</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Platforms.MacOS" Version="*" />
<PackageReference Include="Microsoft.Maui.Platforms.MacOS.Essentials" Version="*" />
</ItemGroup>
<ItemGroup>
<MauiIcon Include="Resources\AppIcon\appicon.png" />
<MauiImage Include="Resources\Images\*" />
<MauiFont Include="Resources\Fonts\*" />
<MauiAsset Include="Resources\Raw\**\*" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
<MauiSplashScreen Include="Resources\Splash\splash.png" />
</ItemGroup>
</Project>
Photo capture uses the native ImageKit picture taker. Apps that call
MediaPicker.CapturePhotoAsync or CaptureVideoAsync must include an
NSCameraUsageDescription entry in Info.plist; the template includes a
default explanation that applications should customize. Video capture uses an
AVFoundation camera session and movie-file output, with native Stop and Cancel
actions. It records camera-only .mov files, so it does not request microphone
permission. Cancelled, failed, empty, or timed-out recordings delete their
partial cache files. Camera permission denial is reported explicitly.
2. Main.cs
using AppKit;
public class MainClass
{
static void Main(string[] args)
{
NSApplication.Init();
NSApplication.SharedApplication.Delegate = new MauiMacOSApp();
NSApplication.Main(args);
}
}
3. MauiMacOSApp.cs
using Foundation;
using Microsoft.Maui.Platforms.MacOS.Platform;
[Register("MauiMacOSApp")]
public class MauiMacOSApp : MacOSMauiApplication
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
4. MauiProgram.cs
using Microsoft.Maui.Platforms.MacOS.Hosting;
using Microsoft.Maui.Platforms.MacOS.Essentials;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiAppMacOS<App>()
.AddMacOSEssentials()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
});
return builder.Build();
}
}
5. App.cs
public class App : Application
{
protected override Window CreateWindow(IActivationState? activationState)
=> new Window(new MainPage());
}
Building / running the sample
dotnet build platforms/MacOS/MacOS.slnx
dotnet run --project platforms/MacOS/samples/MacOS.Sample/
Native runtime scenarios
On macOS, run a registered scenario through the shared native host:
export NUGET_PACKAGES="$PWD/.packages"
python3 -B platforms/MacOS/tests/MacOS.RuntimeTests/run.py \
--scenario layout --evidence "$PWD/artifacts/layout-run"
It opens an AppKit window and mutates a MAUI layout after its handler connects.
It checks nested child bounds, native insertion order, replacement, removal,
clear, and re-addition without resizing the window. Failures exit with code 1;
success prints a PASS line for each of the six cases and exits with code 0. A 90-second
watchdog fails a hung run.
This executable uses the AppKit main thread and is not a dotnet test project.
Building it on Windows does not validate AppKit behavior. For a before/after
comparison, run the same executable with LayoutHandler's constructor passing
only Mapper (the original behavior), then with Mapper, CommandMapper.
The original behavior must fail the first dynamic addition check.
The shared AppKit runtime CI matrix performs that comparison on a
GitHub-hosted macOS runner. Its appkit-runtime-layout-default artifact contains both
process logs, native view screenshots and managed/native bounds after addition.
Screenshots use Aqua appearance and composite transparent view backgrounds over
white so native text remains readable in dark artifact viewers.
The required evidence directory also receives strict machine-readable terminal
results and assertion counts. Hosted execution is distinct from a local desktop run.
See the shared host contract to add a scenario,
version matrix entry or scoped fixture assets without another application/project.
Portable MacOS.Tests remains independent of native AppKit execution.
The same host also registers dialog-registration (the public typed MAUI 11
contract, the isolated MAUI 10 compatibility proxy, and singleton semantics) and
dialogs (real Page action sheet, prompt
and alert completion with native-sheet screenshots). The AppKit workflow
runs every native scenario on the newest MAUI 10 ($(MacOSMaui10Version)) and
MAUI 11 ($(MacOSMaui11Version)) releases; native dialogs use an exact
missing-subscription baseline and bounded fixed run.
Unit tests
The platform-neutral tests exercise the backend's managed lifecycle code using real MAUI
windows and handlers. They target net10.0 and net11.0 and do not require AppKit,
Xcode, or MAUI workloads:
dotnet test platforms/MacOS/tests/MacOS.Tests/MacOS.Tests.csproj
The AppKit CI workflow and official macOS product build also run these tests. Native window notifications and rendering still require testing in a running macOS app.
Bundled resources
On .NET 11, the package consumes Resizetizer's MauiProcessedImage,
MauiProcessedFont, and MauiProcessedAsset outputs as Apple SDK
BundleResource items, including files linked from outside the head project.
Images are bundled as Contents/Resources/Images/<filename> and fonts as
Contents/Resources/Fonts/<filename>. Raw assets use LogicalName relative to
Contents/Resources (or the filename when no logical name is supplied), matching
IFileSystem.OpenAppPackageFileAsync. Backslashes in logical names are normalized.
The MAUI mapping replaces the SDK's default resource entry for the same source file;
unrelated BundleResource items are unchanged.
For apps that intentionally manage all these paths using custom BundleResource items,
set EnableMacOSMauiResourceMapping to false to retain that mapping instead.
Images are processed by Resizetizer, including resizing and SVG conversion, before
Apple collects bundle resources. Native resource outputs, including unpacked library
resources, participate in MSBuild's incremental clean so renamed or removed assets
do not survive in the next app bundle. A missing Apple SDK per-library resource
cache invalidates its matching native stamp so unchanged publish builds retain
referenced resources rather than treating an incomplete cache as up to date. The
MAUI 10 compatibility target retains the prior raw-item mapping and is isolated
from the .NET 11 path. Image names and font names must be unique within their respective bundle directories.
Use LogicalName to preserve nested raw-asset paths.
MauiSplashScreen uses the same standard item syntax and is promoted through the
image pipeline so its processed image is available in Contents/Resources/Images.
Native macOS does not define an operating-system launch-screen contract, so AppKit
does not automatically display that image before the first window.
On .NET 11, Razor static web assets are converted by the standard MAUI Blazor targets
and flow through MauiProcessedAsset. .NET 10 uses the compatibility static web
asset bridge; neither framework requires a manual BundleResource glob for wwwroot.
The standalone package-resource acceptance gate uses supported dotnet publish,
expands the resulting .pkg with pkgutil --expand-full without installing it,
and verifies the installed payload's resource bytes and stale-file removal before
checking collision rejection. Logical names use macOS's decomposed Unicode form:
productbuild normalizes its BOM names, and mismatched physical filenames can be
omitted from the installer payload on case-sensitive filesystems. Canonically
equivalent names are compared without changing resource bytes. Distinct resource
files targeting the same bundle path fail with MAUIAPPKIT001 rather than allowing
the native SDK to silently select one. Apple SDK 27.2.11039 does not support
publish --no-build: it invokes Build through GetApplicationArtifactsDependsOn
and fails with NETSDK1085 (upstream explanation).
That unsupported operation is not an AppKit acceptance requirement; GTK and WPF
retain their strict successful no-build publish checks.
The bundle-resources scenario runs inside the shared MacOS.RuntimeTests host,
using external image/font/raw fixtures and a local raw item also matched by the
SDK glob. On macOS with Xcode and the MAUI/macOS workloads, point the runner at
freshly built core and Essentials packages and a new evidence directory:
export RUNTIME_TEST_PACKAGES="$PWD/artifacts/packages"
python3 -B platforms/MacOS/tests/MacOS.RuntimeTests/run.py \
--scenario bundle-resources --evidence "$PWD/artifacts/resources-run"
The scenario's stage driver composes the common build/launch runner: historical
target reproduction, clean package-consumer rebuild, incremental build and
dotnet publish without an installer. Each native run verifies the produced .app,
MAUI image/label handlers and raw content through registered IFileSystem.
Logical paths include spaces, renamed assets and equal filenames in different
folders. Shipping targets perform the bundling; the harness never copies resources.
The same host also runs item-metadata assertions for normal mapping, platform guards
and opt-out. Its package mode rejects ProjectReferences.
The existing native-runtime CI matrix supplies the newly packed packages and uploads
appkit-runtime-bundle-resources-default with strict terminal results, native captures,
bundle inventory, package references and stage binlogs. All native rows wait for the
product build; optional matrix packages and workloads inputs reuse common setup.
These checks require macOS; item-mapping checks alone on Windows are not proof of
rendering.
MAUI DevFlow integration
The sample app supports the optional in-process MAUI DevFlow agent:
dotnet run --project platforms/MacOS/samples/MacOS.Sample/ -p:EnableMauiDevFlow=true
This exposes a local HTTP API and MCP server for inspecting the running app's visual tree,
capturing screenshots, automating interactions, and more. See src/DevFlow/ and the
maui-platform-backend skill's devflow-integration.md reference for details.
License
MIT — see LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-macos26.0 is compatible. net11.0-macos27.2 is compatible. |
-
net10.0-macos26.0
- Microsoft.AspNetCore.Components.WebView.Maui (>= 10.0.110)
- Microsoft.Maui.Controls (>= 10.0.110)
- Microsoft.Maui.Platforms.MacOS (>= 0.1.0-preview.16.26575.2)
-
net11.0-macos27.2
- Microsoft.AspNetCore.Components.WebView.Maui (>= 11.0.0)
- Microsoft.Maui.Controls (>= 11.0.10)
- Microsoft.Maui.Platforms.MacOS (>= 0.1.0-preview.16.26575.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Microsoft.Maui.Platforms.MacOS.BlazorWebView:
| Package | Downloads |
|---|---|
|
Microsoft.Maui.DevFlow.Blazor
Enable browser developer tools and Playwright MCP automation for .NET MAUI Blazor Hybrid apps. Connects Chrome DevTools Protocol to BlazorWebView via Chobitsu. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-preview.16.26575.2 | 0 | 11/26/2026 |
| 0.1.0-preview.15.26574.3 | 46 | 11/25/2026 |
| 0.1.0-preview.14.26573.4 | 155 | 11/23/2026 |
| 0.1.0-preview.14.26573.2 | 57 | 11/23/2026 |
| 0.1.0-preview.14.26567.2 | 1,055 | 11/17/2026 |
| 0.1.0-preview.14.26555.2 | 78 | 11/6/2026 |
| 0.1.0-preview.14.26531.2 | 113 | 10/31/2026 |
| 0.1.0-preview.13.26526.5 | 94 | 10/26/2026 |
| 0.1.0-preview.13.26512.5 | 117 | 10/12/2026 |
| 0.1.0-preview.12.26421.1 | 556 | 8/21/2026 |
| 0.1.0-preview.12.26368.2 | 152 | 7/18/2026 |
| 0.1.0-preview.12.26358.3 | 115 | 7/8/2026 |
| 0.1.0-preview.11.26317.2 | 131 | 6/17/2026 |
| 0.1.0-preview.10.26274.3 | 124 | 5/24/2026 |
| 0.1.0-preview.9.26258.5 | 116 | 5/11/2026 |
| 0.1.0-preview.8.26256.5 | 144 | 5/6/2026 |