I think I've found a bug with SwiftUI TabView selection binding on Mac Catalyst 18.
This code prints to the console when the SceneStorage variable for the TabView selection changes.
If you run the code below on iOS and change the tab, the selection prints to the console indicating the SceneStorage variable has changed.
If you run the code below on Mac Catalyst 18 in Sequoia and change the tab, the selection does not print to the console indicating the SceneStorage variable has not changed.
Looking for input please before I turn this over to Apple code-level support.
//
// ContentView.swift
// tabview-catalyst-issue
//
import SwiftUI
import os.log
enum TabDisplay: String, CaseIterable, Identifiable {
case list
case grid
var id: String { self.rawValue }
}
struct ContentView: View {
@SceneStorage("selectedTabView") var selectedTabView = TabDisplay.list
var body: some View {
VStack {
TabView(selection: $selectedTabView) {
Text("LIST")
.tabItem {
Image(systemName: "list.bullet")
Text("List")
}
.tag(TabDisplay.list)
Text("GRID")
.tabItem {
Image(systemName: "rectangle.split.3x3")
Text("Grid")
}
.tag(TabDisplay.grid)
}
}
.padding()
.onChange(of: self.selectedTabView, perform: { value in
// Added to show that the TabView binding doesn't work in Mac Catalyst 18
print(value)
})
}
}
#Preview {
ContentView()
}
Hi @SRiggs ,
This is a known issue, can you please test with Xcode 16.1 beta 3 if you have not already? https://developer.apple.com/download/applications/
Also, which macOS are you on? the latest is macOS 15.1 beta 6.
Thanks!