IOS 18 update causes toolbar contents to not show

I have an app with a TabView containing a view representable containing a SwiftUI View with a toolbar. The representable is providing the toolbar while the .toolbar modifier provides the content.

Everything works normally on iOS 17, but on iOS 18 the toolbar contents are not showing.

Is this a iOS 18 bug?

See the code below for a simplified example.

import SwiftUI

@main
struct TestApp: App {
    @State var selection: String = "one"
    var body: some Scene {
        WindowGroup {
            TabView(selection: $selection) {
                Representable()
                    .tabItem {
                        Text("One")
                    }
                    .tag("one")
            }
        }
    }
}

struct Representable: UIViewControllerRepresentable {

    let navigationController = UINavigationController()
    func makeUIViewController(context: Context) -> UINavigationController {
        navigationController.pushViewController(UIHostingController(rootView: ToolbarView()), animated: false)
        return navigationController
    }

    func updateUIViewController(_ uiViewController: UINavigationController, context: Context) {}
}

struct ToolbarView: View {
    var body: some View {
        NavigationLink("Navigate") {
            ToolbarView()
        }
        .toolbar {
            ToolbarItem(placement: .principal) {
                Text("Top")
            }
        }
    }
}

@MatiasVian I wasn't able to reproduce the issue. Could you verify and test the behaviour on iOS 18 beta 7 ? Thanks

Sorry, I should have specified I was using iOS 18.1 beta 2, however I get the same result running on beta 7. Attached is a comparison of iOS 17.2 and iOS 18 beta 7 - what I am missing is the "Top" in the toolbar.

I have the same issue. Your code illustrates the problem perfectly.

I also have the same issue

Similar issue here with the latest iOS 18 beta. For us, the principal placement causes the tab bar to increase, while looking good with previous iOS versions.

I have a similar issue. I used .tabViewStyle(.sidebarAdaptable), but in iPadOS 18, my .toolbarTitleMenu or ToolbarItem(placement: .principal) content cannot be displayed. Using NavigationSplitView in iOS 17 works fine.

Same issue here - the icon stopped appearing on iOS 18. My snippet:

.toolbar {
            ToolbarItem(placement: .topBarTrailing) {
                Button(action: {
                    helpTapped()
                }, label: {
                    Image(asset: .helpDefault)
                        .renderingMode(.template)
                })
            }
        }

i have the same issue on ios 18 beta 7

Similar issue(s) here. Please file feedback. The issues below are all still happening on iPadOS 18.2 Beta 2

FB14855728 - Navigation bar background transparent (and unmodifiable) on iPadOS 18.x

FB14849205 - ToolbarTitleMenu not showing on iPadOS 18.x

FB15164292 - On a navigation bar created by a DocumentGroup, all customizable items from the toolbar appear by default on iPadOS 18.1 beta 4

FB14855668 - statusBarHidden(_:) view modifier not respected on iPadOS 18.x

For me it is happens when in .navigationBarTrailing nothing, if I set

.toolbar {
                        ToolbarItem(placement: .navigationBarTrailing) {
                            Spacer(minLength: 20) // just something
                        }
                    }

.principal starts to appear (but with delay)

IOS 18 update causes toolbar contents to not show
 
 
Q