From 307ee6d1e9a79ed3cb3baca611eacc5b8e394779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwas=CC=81niewski?= Date: Thu, 4 Dec 2025 12:35:29 +0100 Subject: [PATCH] fix: exclude macOS from iOS 26+ bottom accessory APIs --- .changeset/cold-mice-fold.md | 5 +++++ .../ios/BottomAccessoryProvider.swift | 2 ++ .../ios/TabView/NewTabView.swift | 11 ++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 .changeset/cold-mice-fold.md diff --git a/.changeset/cold-mice-fold.md b/.changeset/cold-mice-fold.md new file mode 100644 index 00000000..0274f5f9 --- /dev/null +++ b/.changeset/cold-mice-fold.md @@ -0,0 +1,5 @@ +--- +'react-native-bottom-tabs': patch +--- + +fix: macos bottom accessory view compilation diff --git a/packages/react-native-bottom-tabs/ios/BottomAccessoryProvider.swift b/packages/react-native-bottom-tabs/ios/BottomAccessoryProvider.swift index 31914b17..539efee7 100644 --- a/packages/react-native-bottom-tabs/ios/BottomAccessoryProvider.swift +++ b/packages/react-native-bottom-tabs/ios/BottomAccessoryProvider.swift @@ -8,6 +8,7 @@ import SwiftUI self.delegate = delegate } + #if !os(macOS) @available(iOS 26.0, *) public func emitPlacementChanged(_ placement: TabViewBottomAccessoryPlacement?) { var placementValue = "none" @@ -18,6 +19,7 @@ import SwiftUI } self.delegate?.onPlacementChanged(placement: placementValue) } + #endif } @objc public protocol BottomAccessoryProviderDelegate { diff --git a/packages/react-native-bottom-tabs/ios/TabView/NewTabView.swift b/packages/react-native-bottom-tabs/ios/TabView/NewTabView.swift index 593b65de..d6993158 100644 --- a/packages/react-native-bottom-tabs/ios/TabView/NewTabView.swift +++ b/packages/react-native-bottom-tabs/ios/TabView/NewTabView.swift @@ -67,7 +67,11 @@ struct ConditionalBottomAccessoryModifier: ViewModifier { } func body(content: Content) -> some View { - if #available(iOS 26.0, macOS 26.0, tvOS 26.0, visionOS 3.0, *), bottomAccessoryView != nil { + #if os(macOS) + // tabViewBottomAccessory is not available on macOS + content + #else + if #available(iOS 26.0, tvOS 26.0, visionOS 3.0, *), bottomAccessoryView != nil { content .tabViewBottomAccessory { renderBottomAccessoryView() @@ -75,18 +79,22 @@ struct ConditionalBottomAccessoryModifier: ViewModifier { } else { content } + #endif } @ViewBuilder private func renderBottomAccessoryView() -> some View { + #if !os(macOS) if let bottomAccessoryView { if #available(iOS 26.0, *) { BottomAccessoryRepresentableView(view: bottomAccessoryView) } } + #endif } } +#if !os(macOS) @available(iOS 26.0, *) struct BottomAccessoryRepresentableView: PlatformViewRepresentable { @Environment(\.tabViewBottomAccessoryPlacement) var tabViewBottomAccessoryPlacement @@ -115,3 +123,4 @@ struct BottomAccessoryRepresentableView: PlatformViewRepresentable { } } } +#endif