Xcode 7.1 Swift 2 Unknown Class in Interface Builder File

Xcode 7.1 Swift 2 Unknown class in Interface Builder file

In storyboard below the Custom Class field the module is set to None. Change that to your app module or just remove and enter class again, it should set to default like this:

Sample Image

How can I fix an error in Xcode that shows an unknown class in Interface Builder

I find the problem.

I deleted the class some time ago, but didn't remove from the ViewController before remove the file.

I created the file again attach to the view Controller.

After that I remove the file from the view Controller, I create another file and put it in the viewController.

The error has gone now.

Unknown class in Interface Builder file - Xcode 8 Swift 3

What ended up solving my problem was creating a new project and seeing how the original Main.storyboard references its .swift file in the XML, which looks like this

                <viewController id="BYZ-38-t0r" customClass="ViewController" customModule="Sandbox" customModuleProvider="target" sceneMemberID="viewController">

where the important aspect is customClass="ViewController"

By taking this, and editing my project's TutorialView.storyboard by hand and adding in customClass="TutorialViewController I resolved the error.

Unknown class MyClass in Interface Builder file in Swift

A similar line in swift would be AddToDoItemViewController.self. All that really matters is you call your view controller from swift code so the linker knows to include that file.

Xcode 6 Bug: Unknown class in Interface Builder file

I resolved this issue as I was typing the question. I figured I'd answer my question and leave it here for anyone else who may face this issue when using Xcode 6 beta 4.

To resolve this issue, you need to select each of your custom class objects in Storyboard (this includes any custom views, even the custom view controllers themselves).

Then with those objects selected, open the identity inspector and under "Custom Class" you should see the Module option. Finally:

  • Click inside the Module text box, and press enter.
  • Or (update 2022), check the "Inherit Module From Target" option.

That's it! The current module for all of my custom objects must have been internally incorrectly set somehow in Xcode 6 beta 4. But there was no visual indication of this in the inspector.

Note that if pressing enter inside the Module text box doesn't work, try selecting the arrow to the right and manually select your current module, then clear the text box and press enter. You can also try pressing enter inside the class text box (although this usually is to resolve a different issue).

Here is an image to make things more clear:
Sample Image

Unknown class QuoteDetailViewController in Interface Builder file with Xcode 12

So, I said that in the QuoteDetailViewController I have this code.

import UIKit

class QuoteDetailViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let quoteViewController = segue.destination as? QuoteDetailViewController {
if let selectedQuote = sender as? String {
quoteViewController.title = selectedQuote
}
}
}
}

The error was that the function prepare must be in the QuoteTableViewController.



Related Topics



Leave a reply



Submit