Creating a Window in MacOS 10.13.3 Programmatically



I seem to have a problem overriding a nib name of a window controller for a window I am creating programmatically. My Xcode keeps suggesting NSNib.Name? as a var type for windowNibName property of MainWindowController and I am not able to convert it to String either. Funny thing is that there is no such problem in my projects created a year ago. There, Xcode suggestions are of the same String type. Could anybody please suggest anything helpful?


MacOS 10.13.3, Xcode 9.2
Error text: “Property ‘windowNibName’ with type ‘String?’ cannot override a property with type ‘NSNib.Name?’”


Looks like you are now using the latest and greatest Xcode :slight_smile:

Have you tried something like this?

let nibFileName = NSNib.Name ("HootHootWindow")
let wc = NSWindowController (nibFileName)


Thanks, mate! Thats precisely the problem I was having. Had to do plenty of googling before I found this document Ended up solving the issue this way:

override var windowNibName: NSNib.Name? {
return NSNib.Name(rawValue: “MainWindowController”)

But I like your approach too.

Btw, do you keep track of the changes they keep introducing to Swift? If you do, would you care to share with me how, for instance, have you found out about this particular issue? It was not too easy to google out this crap I must say.


No, I don’t. But when something breaks after starting to use the new version of the Xcode, I go and check the API.