How to disable the "Show Tab Bar" option in a macOS Catalyst App

Viewed 593

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?

Unnecessary tab bar

Here's the option I would like to completely disable:

enter image description here

2 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:

Class _nswindow = NSClassFromString(@"NSWindow");
[_nswindow setAllowsAutomaticWindowTabbing:NO];

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 called UIApplicationSupportsTabbedSceneCollection

<key>UIApplicationSceneManifest-macos</key>
<dict>
    <key>UIApplicationSupportsMultipleScenes</key>
    <true/>
    <key>UIApplicationSupportsTabbedSceneCollection</key>
    <false/>
</dict>

Source - WWDC 21 Presentation: What's new in Mac Catalyst (@7:45)

Related