macOS Sequoia – NSToolbar on Catalyst disappeared

Hello,

I have a macOS Catalyst app that I now began updating and building against the iOS 18/macOS Sequoia SDKs. Most things appear to be working just fine as before, apart from my NSToolbar.

At the root of my app I am presenting a UISplitViewController which gets a custom SidebarViewController and a UITabBarController as its viewControllers.

Then at same point in the apps lifecycle the UITabBarController presents another ViewController modally. I then associate the controllers window with a custom NSToolbar like this:

let toolbar = NSToolbar(identifier: "mainToolbar")
toolbar.displayMode = .iconAndLabel
toolbar.delegate = self
toolbar.allowsUserCustomization = false

titleBar.toolbarStyle = .automatic
titleBar.titleVisibility = .hidden
titleBar.toolbar = toolbar

I also disable automatic NSToolbar hosting via: https://developer.apple.com/documentation/uikit/uinavigationbardelegate/3987959-navigationbarnstoolbarsection (returning .none).

Now all of this worked fine on macOS Sonoma and previous versions but on Sequoia my custom toolbar refuses to show up.

My suspicion is that is has something to do with the new tab and sidebar behaviour introduced with the new SDKs (https://developer.apple.com/documentation/uikit/uinavigationbardelegate/3987959-navigationbarnstoolbarsection).

For now within my UITabBarController I was able to revert to the old look using:

if #available(iOS 18.0, *) {
    mode = .tabSidebar
    sidebar.isHidden = true
    isTabBarHidden = true
}

This result in a look similar to the previous macOS version but my NSToolbar unfortunately remains hidden. Is there an easy fix for this? Since I am a solo developer I would prefer to spend my available resources currently on other features and adopt the new tab/sidebars a couple months down the line.

Appreciate any help and hints, thanks!

There used to be a toolbar here on the right side. ↑

Okay so what I've discovered so far is that for some reason the toolbars NSToolBarDelegate is being reset to nil (in the code above you can see that I indeed set it) and thus no items are being added. I have absolutely no idea why though and tested countless different setups. The same exact app runs fine on Sonoma, so what could have changed here?

I finally found the culprit! »Dead Code Stripping« was set to »Yes«. If I set it to no, the toolbar magically appears and the delegate is set properly. Can anyone explain to me why that would happen or is it a bug? My toolbar code is wrapped in a compiler condition #if targetEnvironment(macCatalyst)…#endif but that's the only thing I could think of.

macOS Sequoia – NSToolbar on Catalyst disappeared
 
 
Q