Summary
When using .tabViewBottomAccessory
in SwiftUI and conditionally rendering it based on the selected tab, the app crashes with a NSInternalInconsistencyException
related to _bottomAccessory.displayStyle
.
Steps to Reproduce
- Create a SwiftUI
TabView
using a@SceneStorage
selectedTab
binding. - Render a
.tabViewBottomAccessory
with conditional visibility tied toselectedTab == .storage
. - Switch between tabs.
- Return to the tab that conditionally shows the accessory (e.g., “Storage”).
Expected Behavior
SwiftUI should correctly add, remove, or show/hide the bottom accessory view without crashing.
Actual Behavior
The app crashes with the following error:
Environment
- iOS version: iOS 26 seed 2 (23A5276f)
- Xcode: 26
- Swift: 6.2
- Device: iPhone 12 Pro
I have opened a bug report with the FB number: FB18479195
Code Sample
import SwiftUI
struct ContentView: View {
enum TabContent: String {
case storage
case recipe
case profile
case addItem
}
@SceneStorage("selectedTab") private var selectedTab: TabContent = .storage
var body: some View {
TabView(selection: $selectedTab) {
Tab(
"Storage", systemImage: "refrigerator", value: TabContent.storage
) {
StorageView()
}
Tab(
"Cook", systemImage: "frying.pan", value: TabContent.recipe
) {
RecipeView()
}
Tab(
"Profile", systemImage: "person", value: TabContent.profile
) {
ProfileView()
}
}
.tabBarMinimizeBehavior(.onScrollDown)
.tabViewBottomAccessory {
if selectedTab == .storage {
Button(action: {
}) {
Label("Add Item", systemImage: "plus")
}
}
}
}
}