Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown class in Interface Builder file - Xcode 8 Swift 3

I ran into the following error

Unknown class TutorialViewController.swift in Interface Builder file.

when renaming the default files Main.storyboard and ViewController.swift to my desired naming convention of TutorialView.storyboard and TutorialViewController.swift respectively.

I renamed the files by physically renaming the file names in Xcode and updating the class name of TutorialViewController.swift.

After renaming, I tried to fix the link from TutorialView.storyboard to TutorialViewController.swift by updating the storyboard's Custom Class to TutorialViewController, which is the correct way to complete the link. This in fact caused the above error.

Disclaimer: I'm aware this is similar to this SO post but I wanted to make this question and answer my solution, as that post does not have an accepted answer. I'm hoping I can save someone all the time it took me to figure this out.

like image 933
Greg Hilston Avatar asked Dec 03 '22 13:12

Greg Hilston


1 Answers

Check if the Inherit from Target is selected in the interface builder to your custom view. That actually did the trick for me.

If your view happens to be within a .bundle file that gets copied to a different target, then you'll need to explicitly set the module target.

If you have multiple targets, then check if the custom class is selected for all the targets or at least the one which you are running.

like image 96
Shruti Avatar answered Dec 19 '22 18:12

Shruti