Disable zoom navigation transitions when running on a Mac

Dismissing any SwiftUI sheet while a .navigationTransition(.zoom) is
registered traps inside UIKit's _UIZoomTransitionController on the Mac
presentation path (macOS 26.4.1, builds 259/261 crash reports). The
same code path is stable on iOS and iPadOS, so this is an Apple
framework bug on Mac that can only be avoided.

Gate both zoom-transition modifiers on a cached runtime check for
isMacCatalystApp / isiOSAppOnMac so the Mac build falls into the
existing no-op branch while iOS and iPadOS keep the zoom animation.
This commit is contained in:
Arkadiusz Fal
2026-07-23 23:09:47 +02:00
parent ce7e9cbde7
commit 41d58f47a3

View File

@@ -9,6 +9,14 @@
import SwiftUI
#if os(iOS)
/// Whether the iOS binary is running on a Mac (Catalyst or "Designed for iPad").
/// Zoom transitions trap inside UIKit's _UIZoomTransitionController when a sheet
/// is dismissed on the Mac presentation path, so they must stay off there.
private let zoomTransitionsRunningOnMac: Bool =
ProcessInfo.processInfo.isMacCatalystApp || ProcessInfo.processInfo.isiOSAppOnMac
#endif
// MARK: - Environment Keys
/// Environment key to pass the navigation transition namespace through the view hierarchy.
@@ -49,7 +57,7 @@ struct ZoomTransitionSourceModifier<ID: Hashable>: ViewModifier {
func body(content: Content) -> some View {
#if os(iOS)
if zoomTransitionsEnabled, let namespace {
if zoomTransitionsEnabled, !zoomTransitionsRunningOnMac, let namespace {
content
.matchedTransitionSource(id: id, in: namespace)
} else {
@@ -75,7 +83,7 @@ struct ZoomTransitionDestinationModifier<ID: Hashable>: ViewModifier {
func body(content: Content) -> some View {
#if os(iOS)
if zoomTransitionsEnabled, let namespace {
if zoomTransitionsEnabled, !zoomTransitionsRunningOnMac, let namespace {
content
.navigationTransition(.zoom(sourceID: id, in: namespace))
} else {