Unknown class in Interface Builder file. Xcode 6 a

2019-04-03 04:05发布

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 :(

3条回答
劫难
2楼-- · 2019-04-03 04:21

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.

查看更多
smile是对你的礼貌
3楼-- · 2019-04-03 04:26

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.

查看更多
We Are One
4楼-- · 2019-04-03 04:28

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

enter image description here.

查看更多
登录 后发表回答