31

My app uses storyboards and the windows have to use a custom class, MyWindow for example, or at runtime/launching the app, there is an error message saying:

Unknown Window class (null) in Interface Builder file, creating generic Window instead

I just noticed this after upgrading to Xcode 9.1, but I'm not sure if it was there before.

A similar question is here: Xcode 6 Strange Bug: Unknown class in Interface Builder file

Update:

My other project doesn't have this issue. I will investigate it later.

Update2:

In both projects, a window is owned by a custom window controller. I checked the storyboard xml but didn't find anything odd.

mjuarez
  • 16,372
  • 11
  • 56
  • 73
LShi
  • 1,500
  • 16
  • 29

4 Answers4

30

This warning also occurs when I build and run a brand new empty project in Xcode 9.1.

Replacing the default NSWindow with an empty custom class of NSWindow with no changes does remove the error, but that behaviour makes no sense.

Therefore, I'm filing it as a bug.

applehelpwriter
  • 488
  • 3
  • 8
7

I had the same issue after upgrading to Xcode 9.1. To resolve the error you need to replace all instances of NSWindow in storyboards with custom subclasses of NSWindow.

Kaschman
  • 151
  • 5
7

I have the same problem in several projects since the upgrade.

"Unknown Window class (null) in Interface Builder file, creating generic Window instead"

This happens in all Cocoa projects it seems at the moment. Few of them will run properly. However I have no custom window controllers. Replacing the default window controller in Storyboard with a named subclass doesn't change the situation.

Solved: - Creating blank custom window subclass for the default window solves the problem. I was getting thrown by the message appearing after making changes to the project (accidentally deleting my main viewcontroller etc.)

  • 1
    When you say "creating blank custom window subclass for the default window" I'm not sure I follow exactly. Could you explain? Is this just creating a new subclass with no content in it? If so then in my case, that's what I have for my subclass and it still is giving me the error. – Greg Steiner Feb 02 '18 at 23:58
  • Hah it's been a long time since i had this problem. Looking back at one of my projects i can see that in the storyboard the window controller scene contains a window controller which contains a window. This window is set to have a custom window class that has been implemented in source and only contains the `class customWindow : NSWindow { }` class declaration. I seem to remember panicking about this at the time and that seemed to solve it. Maybe the window was missing as it seems to compile now with this window simply set to an NSWindow class! Good luck and i hope you've solved it! – CodeCoordination Feb 04 '18 at 17:51
  • 1
    Thanks! That's the thing about code. No matter how much time passes, someone will end up with the same problem that others solved a decade ago! :) – Greg Steiner Feb 04 '18 at 21:32
2

Follow-Up:

This is solved in the newest XCode update 9.3 (9E145)

Fixed an issue compiling macOS storyboards that resulted in incorrectly logging: "Unknown Window class (null) in Interface Builder file, creating generic Window instead." (34994636)

Pat_Morita
  • 3,355
  • 3
  • 25
  • 36