Creating NSStatusBar.system.statusItem generates console warning

Putting:

let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)

at the top of AppDelegate.swift and no other code at all generates the warning below in the console when the app runs. Looks benign but it sure would be great to not have that happen.

Anyone figure out how to stop this other than muting the warning? I tried all kinds of exotic deferring but that just makes the code brittle and unreadable.

Here's the warning:

It's not legal to call -layoutSubtreeIfNeeded on a view which is already being laid out. If you are implementing the view's -layout method, you can call -[super layout] instead. Break on void _NSDetectedLayoutRecursion(void) to debug. This will be logged only once. This may break in the future.

Xcode 26.5, 26.4 - macOS 26.5.1

Creating NSStatusBar.system.statusItem generates console warning
 
 
Q