dotnet / dotnet/maui

[iOS] Essentials Map uses deprecated MKPlacemark — migrate to MKMapItem(location:address:) for iOS 26+

Open
#36,845 0 comments 1 reaction 0 assignees View on GitHub
area-essentials platform/ios platform/macos
Dominant language
C#
Stars
23.3k
Forks
2k
Avg merge
1d 15h
Merged PRs (30d)
290

Description

### Description

`MapImplementation.TryOpenAsync(double latitude, double longitude, MapLaunchOptions options)` in `src/Essentials/src/Map/Map.ios.watchos.macos.cs` builds an `MKPlacemark` and hands it to `MKMapItem` / `MKMapItem.OpenMaps`.

Apple deprecated `MKPlacemark` in iOS 26 in favour of `MKAddress` and the new `MKMapItem(location:address:)` initializer. The .NET binding reflects that with `[UnsupportedOSPlatform("ios26.0")]`, which turns CA1416 into a build error on the `net11.0-ios26.5` TFM — see #36451.

As a stopgap, #36619 suppresses CA1416 at that call site with a justified `#pragma warning disable`. The API is deprecated but still functional at runtime, so behavior is unchanged. **This issue tracks doing the real migration.**

### What needs to happen

Under an `OperatingSystem.IsIOSVersionAtLeast(26)` guard, construct the `MKMapItem` using the iOS 26 API instead of `MKPlacemark`, preserving the existing semantics:

- `MKMapItem.Name` must still be set from `MapLaunchOptions.Name`.
- `MKLaunchOptions.DirectionsMode` must still be derived from `MapLaunchOptions.NavigationMode`, including `NavigationMode.Default`.
- The launch must still go through `MKMapItem.OpenMaps`.

> [!IMPORTANT]
> The `maps.apple.com` URL scheme is **not** an acceptable substitute here. It cannot carry the pin label without an extra `q=` parameter, and `dirflg` is only honoured when a destination (`daddr`) is present — so `NavigationMode` is silently ignored for a coordinate-only open. This was explored in #36619 and rejected for exactly that reason.

`TryOpenAsync(Placemark, MapLaunchOptions)` also constructs `MKPlacemark`. It isn't flagged by CA1416 because the method carries `[UnsupportedOSPlatform("ios11.0")]`, but it should be revisited as part of the same migration.

This applies to Mac Catalyst as well — `OperatingSystem.IsIOSVersionAtLeast(26)` returns `true` there.

### Test coverage

There is currently no automated coverage for `Map.OpenAsync` — the deep `Essentials` UI test category runs 0 tests, so a regression here would not be caught by CI. Adding coverage alongside the migration would be valuable.

### Links

- Build break that surfaced this: #36451
- Stopgap CA1416 suppression: #36619

Contributor guide

Open the contributing guide

Research direction

Start in src/Essentials/src/Map/Map.ios.watchos.macos.cs, reading MapImplementation.TryOpenAsync(double latitude, double longitude, MapLaunchOptions options) and TryOpenAsync(Placemark, MapLaunchOptions). Review the related issues and the deep Essentials UI test category, which currently runs zero tests. Done means the iOS 26 and Mac Catalyst paths preserve the name, navigation mode, and MKMapItem.OpenMaps behavior without the deprecated API warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, ios
Domain
desktop-dev, mobile-dev
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.