Question

I added a UIView xib file using the root class of MyView.

I created it in the wrong place and so moved it in the project. Same project just a different folder/group.

I then had a problem when running saying...

Unknown Class MyView in Interface Builder file

I couldn't work out what was wrong so I have now deleted the files both from the project and from the directory.

I've done a search using SublimeText2 for the string "MyView" and it doesn't exist anywhere in the project.

I've reset the simulator, cleaned the project and the build folder and deleted derived data.

Still getting the same error.

Any ideas what I can do now?

Was it helpful?

Solution

Sometimes IBuilder 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">

OTHER TIPS

In my case, I solved by checking "Inherit Module From Target" option in Identity Inspector. enter image description here

Go to View -> Utilities Goto File Inspector of .m file

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

If you have multiple targets in your Xcode project, make sure that the class the was mentioned in the error file is compiled for the target you're testing with as well.

appcode is very stubborn in keeping the old xib cached somewhere, and if you have the cached xib and it has the same name that your controller it will try to load it on start.

what I do after deleting a .xib:

  1. delete app from the device
  2. clean build folder in app code
  3. invalidate caches and restart, kill appcode before it starts
  4. delete derived data in xcode
  5. start appcode

step 4 shouldn't be necessary, but my feeling is that without it I am still seeing the deleted .xib

This happened to me when I renamed the custom view class, and the module (in the identity inspector when the view is selected) was blank. It remained blank because Xcode didn't autocomplete the custom class name, hence it left the module blank. All I had to do was re-enter the class name after a build, and then it autocompleted, and selected to appropriate module (Current - Target)

enter image description here

OK, so I deleted all references to the class causing the problem but still nothing.

However, I also had a UIViewController subclass called MyViewController. This wasn't being loaded in any IB file so I don't know how it was causing the problem.

I changed the name to MyOtherViewController.

Build - Run - works.

I don't know how or why but it works now.

I had the same issue when I had multiple class declarations in one file. What I did is I declared a UITableViewCell subclass in one of my view controllers, and forgot to put the UITableViewCell subclass' @implementation in the view controller's .m file.

As my experience, All solutions above had not worked out. Then I had to re-input the custom class in all strayed Xibs. As an amazing result, it just succeeded and what I had done reconnected the lost connection between @interface and IB. Hope to be useful.

I encountered this problem when using a custom class from a SPM packet. Setting the Custom Class Module to the SPM Packet name solved the issue for me.

enter image description here

In my case it was that the class implementation was enclosed into #ifdef but the #ifdef condition had a typo, so the class really was missing

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top