csdnceshi59
ℙℕℤℝ
2014-07-24 04:09

6 Bug: Interface Builder 文件中的未知类

已采纳

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.

转载于:https://stackoverflow.com/questions/24924966/xcode-6-bug-unknown-class-in-interface-builder-file

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

30条回答

  • csdnceshi61 derek5. 7年前

    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

    点赞 23 评论 复制链接分享
  • weixin_41568127 ?yb? 6年前

    These steps work for me.

    1) Clear Derived Data.
    2) Remove .h and .m files
    3) Create .h and .m files Again

    点赞 10 评论 复制链接分享
  • csdnceshi78 程序go 6年前

    My solution was to remove @objc from Custom class definition.

    点赞 10 评论 复制链接分享
  • csdnceshi76 斗士狗 6年前

    I fixed this along the lines of what Laura suggested but I didn't need to recreate the files.

    Using XCode 4, in the Project Navigator, select the .m file that contains the class that it is complaining about

    Go to View->Utilities->Show File Inspector (this will show the File Inspector to the right, with that .m-file info)

    Open the Target Membership section and make sure that your target is selected for this .m-file

    When I added my .m file to my project, it didn't add it to my default target for some reason and that caused me to get the error you mentioned.

    点赞 10 评论 复制链接分享
  • csdnceshi70 笑故挽风 7年前

    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">
    
    点赞 9 评论 复制链接分享
  • weixin_41568110 七度&光 5年前

    I faced this problem in Xcode 8, to resolve it I had to modify storyboard in the text editor.

    In general, look up for your control and remove customModule and customModuleProvider from control entity.

    Did a trick for me.

    点赞 9 评论 复制链接分享
  • csdnceshi54 hurriedly% 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

    点赞 9 评论 复制链接分享
  • csdnceshi56 lrony* 6年前

    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

    点赞 9 评论 复制链接分享
  • csdnceshi54 hurriedly% 6年前

    I solved this by opening my storyboard file as source code and using command-F to search for my unknown class and delete the custom class associated with it.

    点赞 8 评论 复制链接分享
  • csdnceshi62 csdnceshi62 5年前

    This can happen in any Xcode above 6.0. It happened to me after renaming some ViewController classes in Swift project (but I guess it will happen with Obj-C too). You just have to open the interface builder, go to Identity Inspector of ViewController that had its class renamed, select class and press Enter. That will reassign renamed class to selected ViewController and also reset Module Value which gets lost after renaming the class.

    Update for Xcode 8.1 (probably 8.0 too):

    Xcode 8.1 just crashes. Simply and annoyingly just crashes and doesn't print anything. I was chasing that phantom crash for an hour just to find out that it was this very same thing - unassigned class in IB. If you're getting some phantom crashes, double check IB for unassigned classes first.

    点赞 8 评论 复制链接分享
  • weixin_41568208 北城已荒凉 7年前

    I had this problem after I added a new target, then created a new class using the 'New File' dialog but accidentally failed to check the new target as well as the original target in the creation dialog, so the object was only added to my original target. The solution was to delete the source files (remove reference only) then add them back using 'Add Files', this time checking both targets.

    点赞 7 评论 复制链接分享
  • weixin_41568131 10.24 7年前

    Sometimes the controller you are providing loses its target membership from the current application. In that case, pressing enter on the "Module" field will do nothing. Go to the controller and make sure that it has target membership set to the current app.

    点赞 7 评论 复制链接分享
  • csdnceshi72 谁还没个明天 6年前

    The solution was different for me. You need to add the .m of the class to the build phase compiled sources of the target.

    Hope this helps!

    点赞 7 评论 复制链接分享
  • weixin_41568126 乱世@小熊 6年前

    Select your unknown class file, open file inspector tab, check your target name in Target Membership. There you go.

    点赞 7 评论 复制链接分享
  • csdnceshi76 斗士狗 4年前

    My answer: set custom Module equal to the custom Pod name (in my example - custom class name) like on the screenshot attached

    This solution is for a specific case: for custom views classes from Pod (or Carthage) framework.

    Infrastructure: XCode8, Swift3

    enter image description here

    点赞 6 评论 复制链接分享
  • csdnceshi63 elliott.david 5年前

    My solution (Xcode 8.1 Swift 3.0):

    Unknown class xxx in Interface Builder file.

    Open StoryBoard as Source Code and search for xxx. Remove attribute which contains value xxx. Build and Run.

    点赞 5 评论 复制链接分享
  • csdnceshi66 必承其重 | 欲带皇冠 5年前

    I had the same problem.

    In my case, Xcode wasn't adding my custom class to: Target > Build Phase > Compile Sources.

    So I recommend you to verify if your CustomClass.m is there.

    enter image description here

    I hope this helps you.

    点赞 5 评论 复制链接分享
  • csdnceshi57 perhaps? 4年前

    Selecting the proper Module for my Custom Class I solved this problem .

    Here it is :

    enter image description here

    点赞 5 评论 复制链接分享
  • weixin_41568127 ?yb? 7年前

    What only worked for me is actually adding the module name to the xib file...

    Sooo, the xib files look like this:

    mymodule.MyViewController.xib (Module being the name of the proyect, usually)
    

    HORRIBLE solution in my opinion, but that is supposedly how Apple wants us to do it now.

    This question shows 3 possible work arounds back in beta 4 ... apparently Apple has not been very helpful in this situation according to some because they call it "Working as intended."

    点赞 4 评论 复制链接分享
  • csdnceshi56 lrony* 6年前

    I googled everywhere for this. None of the answers work for me until i met 1 dude who asked me to move my project folder to desktop. It just worked automatically. Apparently if you have you project folder to deep in many folders, XCODE actually breaks.

    点赞 4 评论 复制链接分享
  • csdnceshi77 狐狸.fox 7年前

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

    @objc(ForumTopicListViewController) class ForumTopicListViewController
    
    点赞 3 评论 复制链接分享
  • csdnceshi69 YaoRaoLov 7年前

    What @gfrs said is correct, you need to set the Module. However I once ran into an issue that my class wasn't listed in the Class dropdown. Eventually I removed the swift file, re-started Xcode and re-created the file. Finally the class was listed and could be used in Storyboard.

    Also have a look at this answer, which looks like to solve the 'real' problem I encountered.

    点赞 3 评论 复制链接分享
  • weixin_41568196 撒拉嘿哟木头 4年前

    In my case, I added a flag -ObjC to Other Linker Flags in project settings to make it work. Also I tried with -all_load flag and it worked well too.

    enter image description here

    点赞 2 评论 复制链接分享
  • weixin_41568110 七度&光 6年前

    I fixed it by doing exactly the opposite of what ChikabuZ suggested (thanks for pointing it out, though). In the storyboard file, find this:

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

    and replace it with this:

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

    I can't believe how many hours I'm losing getting around bugs in the Swift compiler and Xcode 6

    点赞 2 评论 复制链接分享
  • csdnceshi62 csdnceshi62 5年前

    Check if your class has right Target Membership.

    点赞 1 评论 复制链接分享
  • csdnceshi50 三生石@ 6年前

    I solved this problem by typing in the Module name (unfortunately the drop list will show nothing...) in the Custom Class of the identity inspector for all the View controller and views.

    You may also need to indicate the target provider. To achieve this objective you can open the storyboard in sourcecode mode and add the "customModuleProvider" attribute in both ViewController and View angle brackets.

    点赞 1 评论 复制链接分享
  • csdnceshi51 旧行李 7年前

    I had the same problem with Xcode Version 6.1 (6A1052d). I think the problem appears if you renamed your App / Xcode Project.

    My solution was to add the module name in the interface builder manually.

    点赞 1 评论 复制链接分享
  • weixin_41568127 ?yb? 6年前

    In my case, the class referenced in the Storyboard / xib did not have Target Membership set.

    To fix, give that class's .h and .m files the same Target Membership as your other classes.

    No target membership set.

    点赞 1 评论 复制链接分享
  • csdnceshi77 狐狸.fox 6年前

    I faced the problem when I ported the storyboard from Swift project to Objective-c project, noticing vvkuznetsov's answer, it turned out the two project using same identifier. I "Product -> Clean" and tap Enter key on the Module and Class text field. the issue went away.

    点赞 1 评论 复制链接分享
  • csdnceshi51 旧行李 6年前

    I faced this issue in Xcode 6.1 when I removed Main.storyboard , the LaunchScreen.xib file and the default ViewController classes from my project.

    I fixed it by deleting the Launch Screen File and Main Interface entries from Info.plist

    点赞 1 评论 复制链接分享