Xcode 6 Bug: Unknown class in Interface Builder file

226,069

Solution 1

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. Click inside the Module text box, and press enter.

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: enter image description here

Solution 2

Sometimes Xcode missed customModule="AppName" customModuleProvider="target"

To fix it, open storyboard as source code and replace this line:

<viewController storyboardIdentifier="StoryboardId" id="SomeID" customClass="CustomClass"
sceneMemberID="viewController">

to this:

<viewController storyboardIdentifier="StoryboardId" id="SomeID" customClass="CustomClass"
 customModule="AppName" customModuleProvider="target" sceneMemberID="viewController">

Solution 3

I had this problem after renaming a swift class. Solved it by using the @objc directive:

@objc(ForumTopicListViewController) class ForumTopicListViewController

Solution 4

Project with Multiple Targets

In my case I am working on Project with multiple Targets and the issue was "inherit from Target" was unchecked. Selecting "inherit from target" solved my problem

enter image description here

Solution 5

This worked for me..

Check your compiled source, whether that file(e.g; ViewController.m) is added or not, in my case ViewController file was not added so it was giving me the error..

enter image description here

Share:
226,069
Epic Byte
Author by

Epic Byte

Updated on July 20, 2020

Comments

  • Epic Byte
    Epic Byte almost 4 years

    I upgraded to Xcode 6 beta 4 and now my App continuously crashes with the message

    Unknown class X in Interface Builder file.

    It crashes because supposedly Xcode can't find my custom classes that I have linked in my Storyboard but it shows that they are linked correctly in the Xcode interface.

    I'm positive everything is linked correctly. My only other option may be to delete the entire storyboard file and start from scratch because it might be corrupted somehow.

    Edit: I would also like to add that I tried cleaning, reseting simulator, messing with build phases etc. None of that works.

  • Imre Kelényi
    Imre Kelényi over 9 years
    For me, clicking inside "Module" and pressing enter did not work consistently, but selecting the "Class" field (and pressing enter) always did the job.
  • jamespick
    jamespick over 9 years
    I was getting this error and it happened to be because I changed my app name so all the modules were wrong.
  • Epic Byte
    Epic Byte over 9 years
    @itedi good point, when I get a chance I think I'll add a "Causes" section and list everything that users report caused the issue so we can get a list of what's leading to the issue.
  • Nitin
    Nitin over 9 years
    gfrs: This is not working for me... Have you tried with Xocde 6 beta 6?
  • Maciej Swic
    Maciej Swic over 9 years
    Doesn't work in the GM. What works is typing your module name manually.
  • FluffulousChimp
    FluffulousChimp over 9 years
    What about nibs that are shared between two different build targets, in which case there are two different Swift modules? Is the only solution to port the shared code and resources over to their own module (thereby limiting to iOS 8)...
  • knl
    knl over 9 years
    For me, the target was set correctly, but the class still didn't show up in IB. I noticed, though, that the "Location" of the file showed a path "Relative to Project" instead of "Relative to Group". Removing the file reference AND the group and re-adding it in the project root worked for me.
  • Ryan Smith
    Ryan Smith over 9 years
    I have yet to find a solution. This might be the most frustrating bug I've ever encountered.
  • Joe
    Joe over 9 years
    This fixed it for me, I had @objc class X and changing to @objc(X) class X worked.
  • ndbroadbent
    ndbroadbent over 9 years
    Wow. Thanks for this, I don't think I would have got there otherwise. This fixed an issue that started happening after I added @objc(...) to one of my Swift classes.
  • user1760527
    user1760527 over 9 years
    You can also try to delete your derived data see stackoverflow.com/questions/24039932/…
  • Berend Klein Haneveld
    Berend Klein Haneveld over 9 years
    Had this problem after renaming the default ViewController class from the Single View project template. I wonder what magic was used so that the @objc() directive was not needed for the 'original' ViewController class...
  • WeZZard
    WeZZard over 9 years
    I goes the opposite side. I had specified the module name in Storyboard file but also added @objc directive.
  • Maciej Swic
    Maciej Swic about 9 years
    Actually in my case i had to remove customModuleProvider, then the error went away.
  • Ruud Visser
    Ruud Visser about 9 years
    The solution was different for me. You need to add the .m of the class to the build phase compiled sources of the target.
  • Olyve
    Olyve about 9 years
    This error was caused for me by creating a new class and subclassing it from an already existing class I created. Not sure why that would cause that though.
  • Ed Manners
    Ed Manners about 9 years
    Guillermo, still happening in Xcode as of end of March!
  • Sakiboy
    Sakiboy about 9 years
    @MaciejSwic Removing the customModuleProvider did it for me as well, thank you!
  • Alfro
    Alfro about 9 years
    I got the same issue but I only get the error message in console log without the app crash. And I've tried your solution, but my module name is empty so I've no choice but to leave it. Strange
  • SleepsOnNewspapers
    SleepsOnNewspapers about 9 years
    what about for xib files?
  • Luke
    Luke about 9 years
    Still happening... it's things like this that make me want to cry :(
  • John
    John about 9 years
    This worked for me. ObjC/Swift hybrid project. New VC + Xib in Swift. Xib was not working. VC was blank. Added this, works.
  • Andrej
    Andrej almost 9 years
    My "Module" field wasn't causing problems. I only had issues with "Class" field, as my class was not selected properly due to copy-paste. After selecting the correct class for "Class" field had no more problems.
  • oarfish
    oarfish almost 9 years
    In my case, I had not added the .m file of the custom class to the Compile Sources list of my target.
  • Ryan Kreager
    Ryan Kreager almost 9 years
    This was the problem for me as well - multiple targets lead to the class file accidentally not being included in the target I was building.
  • sudoExclaimationExclaimation
    sudoExclaimationExclaimation almost 9 years
    for me, I had to manually drag and drop the implementation .m file in the "Compile Sources" section of Build Phases.
  • Nilambar Sharma
    Nilambar Sharma almost 9 years
    Some example with explanation would be great.
  • jaytrixz
    jaytrixz almost 9 years
    This worked for me as well. I even made it work without clearing derived data.
  • Jake Lin
    Jake Lin over 8 years
    I got this problem in Xcode 7 beta 5 again since I got it in Xcode 6 before. This time, this method works for me.
  • Pete Varley
    Pete Varley over 8 years
    I was four hours into the rabbit hole when I finally found this post. Thank you so much. I almost gave up.
  • Benjamin Jimenez
    Benjamin Jimenez over 8 years
    I merged files and misses this in one of my targets, great answer
  • VBaarathi
    VBaarathi over 8 years
    In visual studio there is a similar problem. But over there, we get a clear warning message saying the path is too long and things cannot be added or edited. Not sure if its the same thing with XCODE, but after that episode i keep all my projects either in documents or desktop and never had this problem again. I even gave this advice to someone using Xamarin Studio and it also worked for them...
  • Rajeev Bhatia
    Rajeev Bhatia over 8 years
    @EpicByte I am using 6.3. And an xib I created somehow decided it was too cool to have the module set for it. Don't know what i would've done without your answer!
  • Nicolas Miari
    Nicolas Miari over 8 years
    Removing and re-adding class file worked for me. Thanks!
  • KD.
    KD. over 8 years
    That was life saver. This bug still happens in Nov, 2015 with xcode 7.1.
  • owenfi
    owenfi over 8 years
    Xcode sometimes puts source files in Base.lproj (when creating, or when copy to project if needed is checked when drag and dropping) and this prevents the file from being added to compiled sources, once clean that up, and add it to compiled sources, you must click the class name and hit enter as noted in other comments
  • Kirtikumar A.
    Kirtikumar A. over 8 years
    This was worked for me, thanks a lot Arwin, But still I am not getting that why it's raising such error because I did not modify anything in the class or in IB before
  • Sonic Master
    Sonic Master over 8 years
    It is the end of 2015 right now, and this still worked like a charm! Thank you so much!!!
  • z22
    z22 over 8 years
    Works for XCode 7.1.1 too
  • Tom Fast
    Tom Fast over 8 years
    This issue is still present in XCode 7.2. This solution worked.
  • Opus1217
    Opus1217 over 8 years
    In my case in xCode7.2 this wasn't a conversion issue but popped up when I created a custom UIViewController class and named it incorrectly initially. Not sure it's related, but the solution worked.
  • pkc456
    pkc456 over 8 years
    Epic answer by @EpicByte (y). Very easy way to find the root cause of problem and get fixed(of course).
  • Jacksonkr
    Jacksonkr over 8 years
    @CarmenA You only ever add '.m' files to Compile Sources. This really is the correct (& only) solution for some.
  • timgcarlson
    timgcarlson about 8 years
    In my case I had the custom class in a local framework, and clicking enter in the module field didn't work. I had to manually select the framework in the module field for it to work.
  • Tony Heupel
    Tony Heupel about 8 years
    I had to clear out and reenter the name of my custom class, then it found the module correctly. WThis is with XCode 7.2 as well.
  • Arunabh Das
    Arunabh Das about 8 years
    Thanks for this. This fixed everything on Xcode 7.2!!
  • omarojo
    omarojo about 8 years
    do you guys know what exactly has to be written in the Module field ? Selecting/Deselecting/Reselecting the Class field doesnt change the module field at all. And btw, any of my other VCs have the module set, they all have "None" causing no problem. Why should this one have it ?
  • zic10
    zic10 about 8 years
    Just ran into this on Xcode 7.3 solution worked beautifully.
  • Ahd Radwan
    Ahd Radwan almost 8 years
    does not work for xcode 7.3.1, with swift component in objective-c project
  • Paul Bruneau
    Paul Bruneau almost 8 years
    I just got bit by this AGAIN. I had forgotten about it and spent another couple hours thinking I had hooked a nib up incorrectly or something. Still happens in Xcode 7.3.1!!
  • Fomentia
    Fomentia almost 8 years
    This works, despite having way less upvotes than some other answers. Thank you my saviour!
  • Henrik
    Henrik almost 8 years
    This worked for me, after the issue was introduced by migrating to Swift 3 in the Xcode 8 beta.
  • Alex Bollbach
    Alex Bollbach almost 8 years
    this worked for me to get rid of the warning/error although i noticed that at least the background color specified in my storyboard did show up in the running app despite this console log
  • David Douglas
    David Douglas almost 8 years
    this glitch happened to me after I renamed a collection view cell xib file. But manually selecting module as shown got it working again
  • John Armstrong
    John Armstrong almost 8 years
    Thank you thank you. For posterity, this occurred in my project when I renamed the app. The module name is not updated to the new app name so its trying to reference the class in the old project. It manifested as an unwind segue not firing.
  • t1ser
    t1ser over 7 years
    xcode 8 beta 6 - similar problem, and now resolved. thanks.
  • Oded
    Oded over 7 years
    Worked for my first Swift class in a hybrid project in Xcode 8. I already had @objc but had to make it @objc(ClassName) class ClassName as described.
  • mythicalcoder
    mythicalcoder over 7 years
    Did NOT work for me. :( Neither is the solution of Module name working.
  • buildsucceeded
    buildsucceeded over 7 years
    Can you check git and see what changed inside the storyboard? It would be good to be able to fix this manually if it's simple…
  • mythicalcoder
    mythicalcoder over 7 years
    I haven't used git for this project.
  • rockiesGrizzly
    rockiesGrizzly over 7 years
    thanks for this. it appears that following your suggestion causes Xcode to update the module (under the class in IB) from None to Current. i'm thinking the issue is that simply entering the name w/out hitting enter fails to trigger a module update by Xcode.
  • Dan Rosenstark
    Dan Rosenstark over 7 years
    WTF? This was absolutely necessary for me, thank you. I had to delete the customModule="" customModuleProvider=""
  • ibrahimyilmaz
    ibrahimyilmaz over 7 years
    If we try to publish an application to the app store that contains an error like this, the application is refused without thought.
  • Dan Rosenstark
    Dan Rosenstark over 7 years
    I disagree. I just submitted a build that I had to modify this way to TestFlight and it's ready for Beta Testing... we shall see what happens on the actual app store, but it's an IB bug IMO. Thanks!
  • Johnny
    Johnny over 7 years
    You saved my life. Until xcode 8.2.1 have this problem. I found that it add some parameters into xib file. (Marked with highlight) <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="MyViewCell" id="XdY-Ke-DXa" customClass="MyViewCell" customModule="MyProject" customModuleProvider="target">
  • SafeFastExpressive
    SafeFastExpressive over 7 years
    This was my problem, but while trying various solutions I caused the problem that Epic Byte's answer fixes. You must have your source code in the target you are building, but also in IB you need to set the view controller to be part of the current target.
  • Vee
    Vee over 7 years
    Thank you! My app has multiple targets so I needed to press "enter" in the Module field in order to set it to "Current - (target name)"
  • some_id
    some_id about 7 years
    Good one, merge pbx broke the target membership values.
  • Borzh
    Borzh about 7 years
    Target membership was my problem also, looked everywhere, but thanks to this answer I could solve it.
  • Tamara
    Tamara about 7 years
    I had the same issue with custom pod - setting Module to the podname helped me, You can find here my answer with illustrating screenshot if needed.
  • BigSauce
    BigSauce about 7 years
    This is still an issue in Xcode 8.2.1. Thanks for the helpful answer!
  • Sepehr Behroozi
    Sepehr Behroozi about 7 years
    This is still an issue in Xcode 8.3.1... such a shame
  • Litehouse
    Litehouse about 7 years
    This worked for me. I inadvertently renamed a controller class, so it obviously no longer existed when the view controller was loaded.
  • Alexandre G
    Alexandre G almost 7 years
    Setting module as BWWalkthrough made the messages go for me.
  • gabicuesta
    gabicuesta almost 7 years
    Xcode 8.3.3 user here, thanks, it solved my problem.
  • Rafael Bugajewski
    Rafael Bugajewski over 6 years
    Xcode Version 9.0 beta 6 and the issue isn’t fixed 😕
  • Gabriel Piffaretti
    Gabriel Piffaretti over 6 years
    This is what happened to me, and fortunately found my way out! I was coming here to answer but you were first. Thanks!!!
  • Vexy
    Vexy over 6 years
    Hah! Nice hack :)
  • galactikuh
    galactikuh over 6 years
    I tried several of the other solutions with no luck. This did the trick. For some odd reason one target was missing the one source file that was giving me fits.
  • JaredH
    JaredH about 6 years
    Thanks for posting this. Solved the issue I was seeing very quickly.
  • NSExceptional
    NSExceptional about 6 years
    Note that if you're using Carthage, the dropdown for Module may not show anything but you can just manually type in the name of the module and it'll work
  • Matthew Ferguson
    Matthew Ferguson almost 6 years
    thanks for this. My problem was that there was two storyboardIdentifiers="StoryboardId". I tried refactoring a storyboard that was created with Xcode 7 I believe. it was 3 years old. REBUILD the storyboard from scratch.
  • Wayneio
    Wayneio almost 6 years
    Wow this was answered in 2014 and I still found it happened in June 2018
  • Eldhose
    Eldhose over 5 years
    for me too.. Happened because of some get conflict resolution
  • Kenster999
    Kenster999 over 5 years
    I had a similar situation. (XCode 9.4.1) I created an iOS app called FilesTestA, with a custom UIView called MxFileView (which consisted of MxFileView.swift and MxFileView.xib). Then I added another target: a Today widget ("FilesTestAWidget"). Solution for using MxFileView in the widget: (1) class = "MxFileView"; (2) check "Inherit Module from Target" (or uncheck it and manually enter "FilesTestAWidget"); (3) in the app target, make sure that both MxFileView.swift and MxFileView.xib include FilesTestAWidget in their Target Membership.
  • viper
    viper over 5 years
    You saved my life. The actual problem was we have to Tick Inherit Module From Target option in the storyboard file.
  • Chris Allinson
    Chris Allinson over 5 years
    XCode 10.0 user here
  • Frost
    Frost over 5 years
    Same problem here. If you have @objc(ForumTopicListViewController) it won't find it in Interface Builder you need @objc FormumTopicListViewController class UIViewController
  • Mason
    Mason over 5 years
    This happened to me on a new project from the default template in Xcode 10.1 (a single iOS app target, and 2 test targets). The checkbox was unchecked for all of my custom view controllers (and so the placeholder text was "None"). After going through and checking the checkbox for every custom view controller in my storyboard, the problem was resolved.
  • aman
    aman about 5 years
    When I hit the 'return key' on the custom class it clears out the module to be empty (just on this one scene in the storyboard). and then the module drop down is empty (although I have 2 targets that work with all my other view controllers). Maybe it has something to do with using this storyboard and the class that is not recognized is an objective-c class, whereas the rest of the project is in swift.
  • Arnab
    Arnab about 5 years
    Enabling Inherit Module From Target took the correct target module
  • RichAppz
    RichAppz almost 5 years
    Xcode normally checks the box for you if you change then class - sadly if you use a find and replace it doesn't - Thanks for your post
  • Chris8447
    Chris8447 almost 5 years
    Confirm. This helped me solving the issue.
  • Erik van der Neut
    Erik van der Neut over 4 years
    Oh my... I don't know how I would have figured this out without this post! THANK YOU! This worked for me just now after I converted a custom TableViewCell from Objective C to Swift in Xcode 11.
  • Animator Joe
    Animator Joe over 4 years
    It's 2020, I'm on Xcode 11, and this is still happening. Thank you for this solution though!
  • DevNebulae
    DevNebulae about 4 years
    I usually have this issue when I convert a view controller from Objective-C to Swift. I retype the last letter and press Enter. Should do the trick as well.
  • TMin
    TMin about 4 years
    I did the same thing, but I had accidentally added the Custom View Controllers name to the ViewControllers root view's custom class section. So I was looking to see why View Controller wasn't able to be found when it was the root view the whole time.
  • javi_swift
    javi_swift over 2 years
    Happened with Xcode 12.5.1 and working with this approach. Thanks!