user11843304
user11843304

Reputation:

Why aren't my custom classes appearing in the dropdown in Interface Builder?

I am using Interface Builder and Storyboards to build my app. I am trying to connect my source code to my UIViewController in Storyboard, but none of my classes show up in the Custom Class dropdown menu. This is occurring in Xcode 11 beta 2 and Xcode 11 beta 4.

I've tried some solutions in this Stack Overflow answer, but they are not working. I've already done all of the following:

None of the solutions worked and I have made sure that I was connected a UIViewController to the Storyboard not something else like a UIView. This is occurring with all of my UIViewControllers and UITableViewControllers.

(I wish I could show an image but I do not have enough reputation...)

I expected the UIViewControllers that I have created to appear in the custom class dropdown. I also surprised to find out that manually typing the view controller into the text field does not work. Instead, when I run the project, I just get this message in the console:

Unknown class ViewControllerName in Interface Builder file.

Upvotes: 0

Views: 942

Answers (2)

Casey
Casey

Reputation: 211

It happened to me and I've noticed the Class dropdown was showing classes from another project that I have opened in the background. After closing all the other projects, the drop down finally showing the correct list of classes from the project that I'm working on. Seems like an Xcode storyboard editor bug.

Upvotes: 0

alxlives
alxlives

Reputation: 5212

It appears that your classes aren't added to the project target. Try this:

1) Make sure your classes are added to the right target membership on the Inspectors Panel on the right:

enter image description here

2) Make sure the class inherits the View Controller type:

class CustomViewController: UIViewController

3) Reload xCode and check if the class is enabled:

enter image description here

Upvotes: 1

Related Questions