Ornament Toolbar disappears

I am working on porting my app to work with visionOS. I've come across an issue where ornaments remain hidden when changing views.

I have my view within a TabView and the ornament bar shows the first time but when changing to another tab and back it does not reappear.

I assume this is a bug as it doesn't make sense that it disappears. Has anyone else had this or am I doing something wrong?

I did try to programmatically show and hide but it seems the view is completely removed from the stack and does not return.

Here is the Swift code I am using:

NavigationStack {
	VStack {
		*MainView*
	}
	.toolbar {
		ToolbarItem(placement: .bottomOrnament) {
			*ToolbarView*
		}
	}
}

Same here.

TabView {
    NavigationSplitView {
        ...
        // If you switch between different sub page, the tab bar ornament on the left disappear. 100% reproducible.
    } detail: {
        ...
    }
}

Been experiencing the same issue

Thanks for bringing this up! Please submit a feedback report at feedback.apple.com and post the FB number here so I can follow up on this.

It seems to be because TabView doesn't call the view again. It remains in the background along with its state.

When I use NavigationStack the toolbar reappears because the whole view is called again.

TabView does not do this and instead seems to just hide the view. TabView should redraw the view when you change tabs. Not sure why it behaves this way as seems like an anti-pattern compared to how the rest of SwiftUI works.

I just tried to make TabView redraw the main view with an .id modifier but then it just causes the whole app to crash.

Guessing this is a bug that will be ironed out as most of the native apps use the TabView along with ornaments.

I will raise this with feedback as suggested.

I am experiencing a similar issue. I have a UIKit MapViewController() where I declare a UIHostingOrnament. This is one view of a SwiftUI TabView. I have the below code in my viewIsAppearing.

#if os(visionOS)
mapView = MKMapView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height))
let ornament = UIHostingOrnament(sceneAnchor: .bottom, contentAlignment: .center) {
    ToolbarView()
        .glassBackgroundEffect()
}
self.ornaments = [ornament]
#else
Do other stuff here
#endif

When I select the tab for the Map View the first time, I see the ornament at the bottom, but when I select another tab and then select the Map tab, the ornament has disappeared. I can see that the viewIsAppearing is executing every time I click on the Map tab.

I filed a feedback on this. It is FB13199930.

The issue has been fixed for me in Xcode 15.1 Beta.

This is fixed, as @SpaceMan has pointed out! Thank you all for the feedback you filed

This issue seems to reappear. in Xcode 16.1 beta. While using a tab bar one view has an ornament or ToolbarItem. While switching between the views the ornament disappears unless I forcefully close and reopen the app.

Vstack {
//some code
} .toolbar {
            ToolbarItem( placement: .bottomOrnament) {
                CategoriesOrnament()
            }
        }

And one more thing, the handle for moving and closing the window is showing a gap like the view is there but invisible. Even when forcing the ornament to be .visible

Ornament Toolbar disappears
 
 
Q