Xcode 6 Bug: Unknown class in Interface Builder file
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:
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
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..
Epic Byte
Updated on July 20, 2020Comments
-
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 over 9 yearsFor me, clicking inside "Module" and pressing enter did not work consistently, but selecting the "Class" field (and pressing enter) always did the job.
-
jamespick over 9 yearsI was getting this error and it happened to be because I changed my app name so all the modules were wrong.
-
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 over 9 yearsgfrs: This is not working for me... Have you tried with Xocde 6 beta 6?
-
Maciej Swic over 9 yearsDoesn't work in the GM. What works is typing your module name manually.
-
FluffulousChimp over 9 yearsWhat 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 over 9 yearsFor 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 over 9 yearsI have yet to find a solution. This might be the most frustrating bug I've ever encountered.
-
Joe over 9 yearsThis fixed it for me, I had
@objc class X
and changing to@objc(X) class X
worked. -
ndbroadbent over 9 yearsWow. 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 over 9 yearsYou can also try to delete your derived data see stackoverflow.com/questions/24039932/…
-
Berend Klein Haneveld over 9 yearsHad 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 over 9 yearsI goes the opposite side. I had specified the module name in Storyboard file but also added @objc directive.
-
Maciej Swic about 9 yearsActually in my case i had to remove
customModuleProvider
, then the error went away. -
Ruud Visser about 9 yearsThe solution was different for me. You need to add the .m of the class to the build phase compiled sources of the target.
-
Olyve about 9 yearsThis 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 about 9 yearsGuillermo, still happening in Xcode as of end of March!
-
Sakiboy about 9 years@MaciejSwic Removing the
customModuleProvider
did it for me as well, thank you! -
Alfro about 9 yearsI 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 about 9 yearswhat about for xib files?
-
Luke about 9 yearsStill happening... it's things like this that make me want to cry :(
-
John about 9 yearsThis worked for me. ObjC/Swift hybrid project. New VC + Xib in Swift. Xib was not working. VC was blank. Added this, works.
-
Andrej almost 9 yearsMy "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 almost 9 yearsIn my case, I had not added the
.m
file of the custom class to the Compile Sources list of my target. -
Ryan Kreager almost 9 yearsThis 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 almost 9 yearsfor me, I had to manually drag and drop the implementation .m file in the "Compile Sources" section of Build Phases.
-
Nilambar Sharma almost 9 yearsSome example with explanation would be great.
-
jaytrixz almost 9 yearsThis worked for me as well. I even made it work without clearing derived data.
-
Jake Lin over 8 yearsI 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 over 8 yearsI was four hours into the rabbit hole when I finally found this post. Thank you so much. I almost gave up.
-
Benjamin Jimenez over 8 yearsI merged files and misses this in one of my targets, great answer
-
VBaarathi over 8 yearsIn 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 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 over 8 yearsRemoving and re-adding class file worked for me. Thanks!
-
KD. over 8 yearsThat was life saver. This bug still happens in Nov, 2015 with xcode 7.1.
-
owenfi over 8 yearsXcode 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. over 8 yearsThis 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 over 8 yearsIt is the end of 2015 right now, and this still worked like a charm! Thank you so much!!!
-
z22 over 8 yearsWorks for XCode 7.1.1 too
-
Tom Fast over 8 yearsThis issue is still present in XCode 7.2. This solution worked.
-
Opus1217 over 8 yearsIn 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 over 8 yearsEpic answer by @EpicByte (y). Very easy way to find the root cause of problem and get fixed(of course).
-
Jacksonkr over 8 years@CarmenA You only ever add '.m' files to
Compile Sources
. This really is the correct (& only) solution for some. -
timgcarlson about 8 yearsIn 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 about 8 yearsI 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 about 8 yearsThanks for this. This fixed everything on Xcode 7.2!!
-
omarojo about 8 yearsdo 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 about 8 yearsJust ran into this on Xcode 7.3 solution worked beautifully.
-
Ahd Radwan almost 8 yearsdoes not work for xcode 7.3.1, with swift component in objective-c project
-
Paul Bruneau almost 8 yearsI 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 almost 8 yearsThis works, despite having way less upvotes than some other answers. Thank you my saviour!
-
Henrik almost 8 yearsThis worked for me, after the issue was introduced by migrating to Swift 3 in the Xcode 8 beta.
-
Alex Bollbach almost 8 yearsthis 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 almost 8 yearsthis 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 almost 8 yearsThank 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 over 7 yearsxcode 8 beta 6 - similar problem, and now resolved. thanks.
-
Oded over 7 yearsWorked 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 over 7 yearsDid NOT work for me. :( Neither is the solution of Module name working.
-
buildsucceeded over 7 yearsCan 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 over 7 yearsI haven't used git for this project.
-
rockiesGrizzly over 7 yearsthanks 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 over 7 yearsWTF? This was absolutely necessary for me, thank you. I had to delete the
customModule="" customModuleProvider=""
-
ibrahimyilmaz over 7 yearsIf we try to publish an application to the app store that contains an error like this, the application is refused without thought.
-
Dan Rosenstark over 7 yearsI 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 over 7 yearsYou 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 over 7 yearsThis 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 over 7 yearsThank 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 about 7 yearsGood one, merge pbx broke the target membership values.
-
Borzh about 7 yearsTarget membership was my problem also, looked everywhere, but thanks to this answer I could solve it.
-
Tamara about 7 yearsI 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 about 7 yearsThis is still an issue in Xcode 8.2.1. Thanks for the helpful answer!
-
Sepehr Behroozi about 7 yearsThis is still an issue in Xcode 8.3.1... such a shame
-
Litehouse about 7 yearsThis worked for me. I inadvertently renamed a controller class, so it obviously no longer existed when the view controller was loaded.
-
Alexandre G almost 7 yearsSetting module as
BWWalkthrough
made the messages go for me. -
gabicuesta almost 7 yearsXcode 8.3.3 user here, thanks, it solved my problem.
-
Rafael Bugajewski over 6 yearsXcode Version 9.0 beta 6 and the issue isn’t fixed 😕
-
Gabriel Piffaretti over 6 yearsThis is what happened to me, and fortunately found my way out! I was coming here to answer but you were first. Thanks!!!
-
Vexy over 6 yearsHah! Nice hack :)
-
galactikuh over 6 yearsI 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 about 6 yearsThanks for posting this. Solved the issue I was seeing very quickly.
-
NSExceptional about 6 yearsNote 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 almost 6 yearsthanks 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 almost 6 yearsWow this was answered in 2014 and I still found it happened in June 2018
-
Eldhose over 5 yearsfor me too.. Happened because of some get conflict resolution
-
Kenster999 over 5 yearsI 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 over 5 yearsYou saved my life. The actual problem was we have to Tick
Inherit Module From Target
option in the storyboard file. -
Chris Allinson over 5 yearsXCode 10.0 user here
-
Frost over 5 yearsSame problem here. If you have @objc(ForumTopicListViewController) it won't find it in Interface Builder you need @objc FormumTopicListViewController class UIViewController
-
Mason over 5 yearsThis 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 about 5 yearsWhen 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 about 5 yearsEnabling
Inherit Module From Target
took the correct target module -
RichAppz almost 5 yearsXcode 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 almost 5 yearsConfirm. This helped me solving the issue.
-
Erik van der Neut over 4 yearsOh 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 over 4 yearsIt's 2020, I'm on Xcode 11, and this is still happening. Thank you for this solution though!
-
DevNebulae about 4 yearsI 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 about 4 yearsI 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 over 2 yearsHappened with Xcode 12.5.1 and working with this approach. Thanks!