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:
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:
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
Access the Instance of a Viewcontroller from Another in Swift
How to Zoom a Uiscrollview Inside of a Uicollectionviewcell
How to Get Uiviewcontroller of a Uiview's Superview in iOS
Set Background Color of Active Tab Bar Item in Swift
Calculating Tiles to Display in a Maprect When "Over-Zoomed" Beyond the Overlay Tile Set
Create and Store PDF Document Programmatically Using Swift for iOS
Auto Layout Constraint on Calayer iOS
Chrome iOS - Is It Just a Uiwebview
How to Pop Specific View Controller in Swift
App Crashes on Enabling Camera Access from Settings iOS 8
Service Workers and iOS/Safari
How to Select Range of Values When Using Arc4Random()
How to Get Visible Viewcontroller from App Delegate When Using Storyboard
How to Know Which Is the Default Measure System (Imperial or Metric) on iOS
Change Font of Back Navigation Bar Button
How to Make Both Header and Footer in Collection View with Swift
Error Appstore Connect:Missing Purpose String in Info.Plist File