I have a macOS Catalyst app that supports multiple windows, but it has built in tabs, and that’s why I would like to disable the native Menu Bar’s "Show Tab Bar" option.
As you can see on the image below, it’s actually breaking my layout, and since my app will never use this feature I would like to get rid of it, is there a way to do this?
Here’s the option I would like to completely disable:
3
Answers
This is the solution I was given by an Apple developer last summer, which calls an AppKit method to disable tabs and the menu items:
You need to do the ugly NSClassFtomString thing because AppKit is not available in Catalyst, but it’s okay to ship an app that does this (I do).
Oh and that’s Objective-C not Swift, obviously. Calling “private” API from Swift is tricky; I recommend either bridging to use ObjC or using the Dynamic library like so:
Dynamic.NSWindow.setAllowsAutomaticWindowTabbing(false)
.With Mac OS Monterey you can use the Window tab opt-out in
Info.plist
calledUIApplicationSupportsTabbedSceneCollection
Source – WWDC 21 Presentation: What’s new in Mac Catalyst (@7:45)
I came here looking for the answer in an AppKit app. Turns out you can do this in a Storyboard by selecting your
NSWindow
instance and setting this value:Here, set "Tabbing Mode" to "Disallowed" and those menu items (and that capability) are gone.
And of course, you can do this in code as well:
window.tabbingMode = .disallowed