Setting attributed title to tab doesn't work in Document Based App

Hi,

I'm working on making a Document based app for MacOS using AppKit and I wanted the different documents to be displayed as tabs of the same window which after a lot of research I managed to do using this single line:

windowController.window?.tabbingMode = .preferred

which I added inside the makeWindowControllers function of my Document. I figured that in order to be able to style my tabs I should use this method:

windowController.window?.tab.attributedTitle = ...

But whatever I added after this = didn't do anything to my tabs. For example I tried this:

windowController.window?.tab.attributedTitle = NSAttributedString(string: "Hello", attributes: [NSAttributedString.Key.backgroundColor: NSColor.red])

Weirdly, using this method:

windowController.window?.tab.title = ...

did work but is far more limited than the other one. Maybe I did something wrong in my implementation of the tabs but it seems to work properly when I run it, only the colors and fonts don't match what I'd like to make which is why I wanted to change them using the attributed title.

Here's my full code for the function:

override func makeWindowControllers() {
    let storyboard = NSStoryboard(name: NSStoryboard.Name("Main"), bundle: nil)
    if let windowController =
        storyboard.instantiateController(
            withIdentifier: NSStoryboard.SceneIdentifier("Document Window Controller")) as? NSWindowController {
        addWindowController(windowController)

        windowController.window?.tabbingMode = .preferred
        windowController.window?.tab.attributedTitle = NSAttributedString(string: "hey", attributes: [NSAttributedString.Key.backgroundColor: NSColor.red])

        // Set the view controller's represented object as your document.
        if let contentVC = windowController.contentViewController as? ViewController {
            contentVC.representedObject = content
            contentViewController = contentVC
        }
    }
}

I would really appreciate some help on this issue!

Thanks by advance,

Cyprien