5

I have an error in my Xcode 6.3 interface builder. When i create a new custom class and want to add it to interface builder custom class field. It is not available. I do use Swift as languag.

What I tried:

  • delete derived data
  • reinstall Xcode
  • cleand project
  • created new project
  • Class name is same as file name
  • Superclass and interface builder class are the same

Nothing worked out ;-( Any idea what it could be ?

enter image description here

enter image description here

enter image description here

Lailo
  • 641
  • 1
  • 8
  • 24
  • Are you sure the classname is the same as the file name? – milo526 Apr 17 '15 at 17:17
  • Check if TimerCVC is a subclass of UIViewController and if the file is added as the same target member as your xib/ storyboard file – Duc Apr 17 '15 at 17:37
  • @milo526 As you can see on the pic, classname is the same as filename – Lailo Apr 17 '15 at 17:46
  • @Duc It is a UICollectionViewController and yes the subclass is the needed type. As you can see on the added pic, It is a member of the right target. – Lailo Apr 17 '15 at 17:47
  • You are not the only person to hit this bug. Unfortunately, I've never hit it so I've no experience with it; and I've never seen a reliable explanation of how to solve it. - I notice in your first screen shot that you are relying on autocomplete. What happens if you just type the full name yourself and hit return? – matt Apr 17 '15 at 17:53
  • @matt If i just enter the name I got an error: Custom class not found – Lailo Apr 17 '15 at 17:56
  • Horrible. :( I can't think what else to try except a massive cache cleaning, such as I describe here (and it sounds like you've already done most of this): http://stackoverflow.com/a/6247073/341994 Otherwise it sounds like the project itself is breaking in some way, and I don't know why. – matt Apr 17 '15 at 18:02
  • If you can reproduce the problem in a small project that you are willing to share on github, I'd love to take a look at it. – matt Apr 17 '15 at 18:04
  • @matt The problem is just on my MacBook Pro, I did try it on another Mac but it worked there. It must be something with my Mac. – Lailo Apr 17 '15 at 18:36
  • Hmm. Okay, now I think you should do what I said here, http://stackoverflow.com/a/6247073/341994 - plus delete Xcode preferences file. In other words, we want to try to get this environment as clean as the other environment. – matt Apr 17 '15 at 18:40
  • Not worked, still having the problem. – Lailo Apr 22 '15 at 11:57
  • @lailo Did you ever solve this? Still finding this problem in Xcode 8 and Swift 3... – Greg Hilston Jan 26 '17 at 18:30

2 Answers2

0

I had the same issue and thought it as a bug. But it was my misunderstanding.

What actually happens is:

Custom Class drop down list shows only those custom classes which are subclasses of currently selected object's class.

For example, if we have imageview object in xib and after selecting it, when we see custom class drop down list, it'll show only custom classes inherited from (subclass of) UIImageView.

What I was doing wrong was looking for those custom classses which are subclasses of UIView.

In your case, it might be, not 100% sure, happening due to your TimerCVC is a subclass of UICollectionViewController instead of UIViewController.

Nitesh Borad
  • 4,583
  • 36
  • 51
  • Indeed, I had created a class which subclassed `ViewController` and had `TableViewDelegate` code, but in IB, I had dragged an actual `TableViewController`. –  Nov 19 '19 at 03:03
-4

TimerCVC is not a subclass of UIViewController

Press ctrl-n -> on the left panel choose iOS ->Source -> Cocoa Touch Class -> from the dropdown menu choose UIViewController -> And then fill the name field (automatically Xcode autocomplete with ViewController on the end).

It should look like this

import UIKit

class TimerViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}
  • It is a UICollectionViewController and the error is still here, adding ViewController instead of VC does not make the change ;-( – Lailo Apr 17 '15 at 17:49
  • Try this Window -> Organizer (or Projects if is Xcode 6.3) -> Choose your project and on derrived data click delete -> Restart Xcode – Christos Chadjikyriacou Apr 17 '15 at 18:04