SwiftUI bottom bar triggers UIKitToolbar hierarchy fault and constraint errors

[Submitted as FB21958289]

A minimal SwiftUI app logs framework warnings when a bottom bar Menu is used with the system search toolbar item. The most severe issue is logged as a console Fault (full logs below):

Adding 'UIKitToolbar' as a subview of UIHostingController.view is not supported and may result in a broken view hierarchy. Add your view above UIHostingController.view in a common superview or insert it into your SwiftUI content in a UIViewRepresentable instead.

This appears to be a framework-level SwiftUI/UIKit integration issue, not custom UIKit embedding in app code. The UI may still render, but the warnings indicate an internal hierarchy/layout conflict.

This occurs in simulator and physical device.

REPRO STEPS

  1. Create a new project then replace ContentView with the code below.
  2. Run the app.
  3. The view uses NavigationStack + .searchable + .toolbar with:
    • ToolbarItem(placement: .bottomBar) containing a Menu
    • DefaultToolbarItem(kind: .search, placement: .bottomBar)

EXPECTED RESULT

No view hierarchy or Auto Layout warnings in the console.

ACTUAL RESULT

Console logs warnings such as:

  • "Adding 'UIKitToolbar' as a subview of UIHostingController.view is not supported..."
  • "Ignoring searchBarPlacementBarButtonItem because its vending navigation item does not match the view controller's..."
  • "Unable to simultaneously satisfy constraints..." (ButtonWrapper/UIButtonBarButton width and trailing constraints)

MINIMAL REPRO CODE

import SwiftUI

struct ContentView: View {
    @State private var searchText = ""
    @State private var isSearchPresented = false

    var body: some View {
        NavigationStack {
            List(0..<30, id: \.self) { index in
                Text("Row \(index)")
            }
            .navigationTitle("Toolbar Repro")
            .searchable(text: $searchText, isPresented: $isSearchPresented)
            .toolbar {
                ToolbarItem(placement: .bottomBar) {
                    Menu {
                        Button("Action 1") { }
                        Button("Action 2") { }
                    } label: {
                        Label("Actions", systemImage: "ellipsis.circle")
                    }
                }

                DefaultToolbarItem(kind: .search, placement: .bottomBar)
            }
        }
    }
}

CONSOLE LOG

Adding 'UIKitToolbar' as a subview of UIHostingController.view is not supported and may result in a broken view hierarchy. Add your view above UIHostingController.view in a common superview or insert it into your SwiftUI content in a UIViewRepresentable instead.
Ignoring searchBarPlacementBarButtonItem because its vending navigation item does not match the view controller's. view controller: <_TtGC7SwiftUI32NavigationStackHostingControllerVS_7AnyView_: 0x106014c00>; vc's navigationItem = <UINavigationItem: 0x105530320> title='Toolbar Repro' style=navigator searchController=0x106131200 SearchBarHidesWhenScrolling-default; vending navigation item <UINavigationItem: 0x106db4270> style=navigator searchController=0x106131200 SearchBarHidesWhenScrolling-explicit
Unable to simultaneously satisfy constraints.
	Probably at least one of the constraints in the following list is one you don't want. 
	Try this: 
		(1) look at each constraint and try to figure out which you don't expect; 
		(2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x600002171450 _TtC5UIKitP33_DDE14AA6B49FCAFC5A54255A118E1D8713ButtonWrapper:0x106a31fe0.width == _UIButtonBarButton:0x106dc4010.width   (active)>",
    "<NSLayoutConstraint:0x6000021558b0 'IB_Leading_Leading' H:|-(8)-[_UIModernBarButton:0x106a38010]   (active, names: '|':_UIButtonBarButton:0x106dc4010 )>",
    "<NSLayoutConstraint:0x600002170eb0 'IB_Trailing_Trailing' H:[_UIModernBarButton:0x106a38010]-(8)-|   (active, names: '|':_UIButtonBarButton:0x106dc4010 )>",
    "<NSLayoutConstraint:0x60000210aa80 'UIView-Encapsulated-Layout-Width' _TtC5UIKitP33_DDE14AA6B49FCAFC5A54255A118E1D8713ButtonWrapper:0x106a31fe0.width == 0   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x600002170eb0 'IB_Trailing_Trailing' H:[_UIModernBarButton:0x106a38010]-(8)-|   (active, names: '|':_UIButtonBarButton:0x106dc4010 )>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
Failed to send CA Event for app launch measurements for ca_event_type: 0 event_name: com.apple.app_launch_measurement.FirstFramePresentationMetric
Failed to send CA Event for app launch measurements for ca_event_type: 1 event_name: com.apple.app_launch_measurement.ExtendedLaunchMetrics
SwiftUI bottom bar triggers UIKitToolbar hierarchy fault and constraint errors
 
 
Q