Storyboard uiviewcontroller, 'custom class' not showing in drop down

I have a UIViewController I created in my apps storyboard, as well as a custom UIViewController subclass which I added to the project (and is correctly in the compile phase for my target). However when I go to set the 'Custom Class' property on the view-controller in Storyboard my custom class does not show up on the list.

  • Checked that the class is part of my app's target, not tests'
  • Double checked that it is correctly a subclass of UIViewController
  • Compiled program just to make sure xcode was working with latest information
  • Restarted xcode

What would cause my class to not show up in the 'Custom Class' drop down?


Solution 1:

Two ways I found that solve the problem but they are work arounds:-

  1. Just type the view controllers name in the text field, or
  2. close the project and then reopen it and in the project initialization it places the file on the list.

Solution 2:

If you still have your problem or for those who could have the same problem:

Make sure to select on your storyboard your "ViewController" instead of your "View" (which is automatically selected when you click on the view in the storyboard). The difference between those two is that when the view controller is selected, a blue rectangle pop up around your app. To be sure to select the view controller, open the document outline and select it directly in your storyboard hierarchy.

enter image description hereenter image description hereenter image description here

Solution 3:

I would try the following:

  1. Check that the file implementing the class is part of the build phases (check under target > build phases)
  2. Add the .m file to build phases (if it isn't already).
  3. Restart Xcode.

Solution 4:

You can fix this by editing the XML of your Storyboard.

  1. Right-click your My.storyboard entry in the Project Navigator panel and select the Open As->SourceCode menu choice. Find your view controller entry in the XML, and add the attribute customClass="MyController".

  2. Save the storyboard.

  3. Right-click your My.storyboard entry in the Project Navigator panel again, and select the Open As->Interface Builder - Storyboard menu choice.

The custom class entry will now contain your MyController class name.