Value of type 'UIWindowScene' has no member 'titlebar'

I am using the exact same code from the Apple WWDC19 Session 235:


This code is in the scene(_:, willConnectTo:, options:) method:

#if targetEnvironment(UIKitForMac)
if let windowScene = scene as? UIWindowScene {
    if let titleBar = windowScene.titlebar {
        let toolbar = NSToolbar()
        // Setup toolbar
    }
}
#endif


However, on the 3rd line there, it just tells me that the windowScene property does not have the titlebar property within it.


Am I missing something?

Accepted Reply

You need some import:

If you get a “Value of type ‘UIWindowScene’ has no member ‘titlebar‘" error, you will need to import NSToolbar+UIKitAdditions.h as detailed in the macOS 10.15 Beta Release Notes. This is likely a temporary requirement.


See complete explanation here

h ttps://fleetingpixels.com/blog/2019/6/7/customising-nstoolbar-in-uikit-for-mac-marzipancatalyst

Replies

You need some import:

If you get a “Value of type ‘UIWindowScene’ has no member ‘titlebar‘" error, you will need to import NSToolbar+UIKitAdditions.h as detailed in the macOS 10.15 Beta Release Notes. This is likely a temporary requirement.


See complete explanation here

h ttps://fleetingpixels.com/blog/2019/6/7/customising-nstoolbar-in-uikit-for-mac-marzipancatalyst

Has anyone else encountered errors with NSLayoutConstraint after including NSToolbar+UIKitAdditions.h?

Yes, got an error saying it cannot find Attribute on NSLayoutContraint!