27

I started a vanilla master detail project with swift. If I add a new view controller and set the custom class, then the modules list is empty and it is not possible to choose a module. The error message "Unknown class in Interface Builder file." appears in the console if I run the code. How can I setup the storyboard to know the custom class and module?

How it should be. The two classes from the template are just fine.

How it should be

and how it is

Missing module

I have to add customModule="Target_Name" customModuleProvider="target" to the interface builder source code. That is really annoying! open .storyboard as source code

Update: If I move the whole project directory to another, e.g. to the desktop it works. Looks like my directory with the name "Repository" is broken. Don't know why :(

Lachezar
  • 6,523
  • 3
  • 33
  • 34
zeiteisen
  • 7,078
  • 5
  • 50
  • 68
  • 1
    Perhaps see http://stackoverflow.com/questions/24924966/xcode-6-strange-bug-unknown-class-in-interface-builder-file or http://stackoverflow.com/questions/19401783/unknown-class-in-interface-builder-file. Or search Stack Overflow for `[xcode] interface builder "unknown class"`. – Rob Nov 08 '14 at 13:35
  • 1
    thank you for the update! moving the whole project directory to another location solves this problem! – user848555 Mar 27 '15 at 21:20
  • Agree, I find it to be one of the most annoying bugs in Xcode. Still exists in Xcode 7.0 beta 6. – Evgenii Aug 27 '15 at 05:26

4 Answers4

2

I used to encounter the same issue, I finally found that the StoryBoard's Target Membership has been set incorrectly

enter image description here.

Quanlong
  • 24,028
  • 16
  • 69
  • 79
0

I was getting the same problem but I discovered that I had inadvertently assigned a non-existing custom class to the view object managed by my view controller. So in the storyboard document view, I selected the badly configured view object, then in the identity inspector, deleted the bad custom class displayed for it (by backspacing and hitting return). That took care of the problem.

In my case, the custom class should be assigned to to the view controller, and not the view object managed by the controller.

Lexo
  • 412
  • 4
  • 6
0

I hit a similar issue when I changed the default Xcode project's UIViewController subclass to instead be a subclass of UITableViewController. (I made this change in the class source file, nothing to do with Storyboard).

I then went and typed my new class name into the IB "Class" field of the default "view" in the Storyboard. It would not autocomplete my class name, and then gave the Unknown class in Interface Builder file error when run.

The solution was to delete the default UIViewController object from the Storyboard, then add a new UITableViewController. Then, set that object's Class in IB to be your custom class.

It seems like the original question may be hitting this issue, as the first screenshot's class is ...ViewController and the second is ...TableViewController.

pkamb
  • 33,281
  • 23
  • 160
  • 191
0

I've encountered the same issue and got it fixed. Reading this question gave me an idea to check the Identity Inspector further more and I found that the class Module should be inherit from target instead from a None module as I had.

Try checking the Inherit Module From Target checkbox and rebuild.

Hope it can help someone, obviously your problem has been solved since it was published in 2014.

ytpm
  • 4,962
  • 6
  • 56
  • 113