Xcode 6.1: Unknown class x in Interface Builder file - ios

I came across an issue yesterday where I am not seeing any of my custom classes in Custom Class or Module fields under Identity Inspector. This causes my app to break every time I run it, with error such as 'Unknown class x in Interface Builder file'
I browsed through tens and twenties of solutions (literally!) that were available in Stack and other sites. But none of them is helping at all!
Xcode 6 Strange Bug: Unknown class in Interface Builder file
"Unknown class <MyClass> in Interface Builder file" error at runtime
Unknown class FirstViewController in Interface Builder file
https://parse.com/questions/using-pfloginviewcontroller-and-pfsignupviewcontroller-with-storyboarding-throws-unknown-class-in-interface-builder-file-error
My learning has halted since yesterday due to small sh*** issue, has anybody encountered and resolved this issue before, please advise!
I also thought to re-install xcode but when I saw it was ~2.5G size, I again decided to give it a try and came to Stack!

Sorry, I forgot post how I could fix this issue.
Actually, it appeared to be a silly fix but I think it has to do with links. I simply changed the project folder location with a different name. I chose a folder name other than "iOS". Then it worked.
Hope it might help others.
Thanks

Related

Xcode Unknown class l in Interface Builder file Glitch

I keep encountering what I believe to be a bug in Xcode version Version 9.4.1. My code will run fine, then after making no adjustments to the storyboard/interface that would necessarily affect the ID or any of my outlets, I will get the error Unknown class l in Interface Builder file.
I have tried investigating, but no luck. I can't find any objects in my storyboard with the class l. Last time, I was able to fix the error by hitting undo a few times. However, hitting undo is not fixing the problem this time. Cleaning the project via SHIFT+CMD+K and restarting Xcode also have no affect.
Anyone else run into this error or have any idea how I could fix it?
Update
After opening and closing Xcode a few more times, the problem seems to have "magically" sorted itself out. Odd, right? While I shouldn't look a gift horse in the mouth, I can't help but remain curious about what could've possibly caused this bug in the first place.

IB Designables gives strange warning when using a custom class

I am trying to subclass my UIButton on my Storyboard with a custom swift class that should show the button as a custom Hamburger Button.
I am getting this warning and not seeing the Hamburger button being rendered in Interface Builder, although it will intermittently work.
The Custom class is called NTHamburgerButton, I don't know why the string on characters is appearing before the class name.
IB Designables: Using class UIButton for object with custom class
because the class _TtC6CProjectName17NTHamburgerButton does not exist.
I've encounter the same problem, and I found an answer from other question:
enter link description here
I just Refresh All Views
It works to me. Hope it helps you too.
This question seems to be getting some attention again so I'll give an update.
This issue existed in a Obj-C and Swift mixed project. So the Class in question was a Swift Class.
When making Swift classes available in Obj-C, you can use the following syntax
#objc(NTHamburgerButton) public class NTHamburgerButton : UIButton {}
Otherwise in your {Project-Name}-Swift.h file that Xcode Creates you will see that it generates these unique class names like that from the question.
The only real issue here was that the NTHamburgerButton.swift file was not being included in the Product I was looking at the at time, but if I switched targets, it worked fine. Thus the intermittent issue.
For me both solutions of Codermonk and specialvict was necessary, but not enough.
I also had to turn on Inherit From Target in Interface Builder:
This did the trick for me.
I struggled with this error in Xcode 11 even after applying the other solutions given.
In my case, I had my own #IBDesignable class residing in the main module (so, not from a CocoaPod or other external module). Yet even when specifying an objc(ClassName) for my view class, the auto generated class name was still being used by Interface Builder at build time.
Finally, I removed the module name and module inheritance in IB and that removed the error and got the view preview rendering:
So, the complete solution for me was:
Declare an Objective-C class name for the Swift class
Configure the class in Interface Builder as shown above
Both are seemingly required in Swift as of Xcode 11. Notably, I had no issues with the view at runtime despite removing the module reference. I am also unsure how this solution would look for views imported from other modules.
This started happening to me in Xcode 12.1. Thus far, simply un-checking then re-checking the "Inherit Module From Target" in Interface Builder seems to have solved the problem.

Build failed--attribute must have a defined type

My app crashes on build. Here's the error in it's entirety:
DataModelVersionCompile /Users/AAAAAAA/Library/Developer/Xcode/DerivedData/XXXXXXXXXX-envirswdnpegjccdpxakhoykfnfq/Build/Products/Debug-iphonesimulator/XXXXXXXXXX.app/WMMGDataModel.momd XXXXXXXXXX/WMMGDataModel.xcdatamodeld
cd "/Users/AAAAAAA/Desktop/Everything from DT 1:20:15/App projects/WMMG/XXXXXXXXXX"
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/momc -XD_MOMC_SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk -XD_MOMC_IOS_TARGET_VERSION=8.1 -MOMC_PLATFORMS iphonesimulator /Users/AAAAAAA/Desktop/Everything\ from\ DT\ 1:20:15/App\ projects/WMMG/XXXXXXXXXX/XXXXXXXXXX/WMMGDataModel.xcdatamodeld /Users/AAAAAAA/Library/Developer/Xcode/DerivedData/XXXXXXXXXX-envirswdnpegjccdpxakhoykfnfq/Build/Products/Debug-iphonesimulator/XXXXXXXXXX.app/WMMGDataModel.momd
/Users/AAAAAAA/Desktop/Everything from DT 1:20:15/App projects/WMMG/XXXXXXXXXX/XXXXXXXXXX/WMMGDataModel.xcdatamodeld/WMMGDataModel 5.xcdatamodel:WMMGAccount.attribute: error: WMMGAccount.attribute must have a defined type
/Users/AAAAAAA/Desktop/Everything from DT 1:20:15/App projects/WMMG/XXXXXXXXXX/XXXXXXXXXX/WMMGDataModel.xcdatamodeld:0: error: Compilation failed for data model at path '/Users/AAAAAAA/Library/Developer/Xcode/DerivedData/XXXXXXXXXX-envirswdnpegjccdpxakhoykfnfq/Build/Products/Debug-iphonesimulator/XXXXXXXXXX.app/WMMGDataModel.momd/WMMGDataModel 5.mom'
Command /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/momc failed with exit code 1
The relevant part seems to be:
/Users/AAAAAAA/Desktop/Everything from DT 1:20:15/App projects/WMMG/XXXXXXXXXX/XXXXXXXXXX/WMMGDataModel.xcdatamodeld/WMMGDataModel 5.xcdatamodel:WMMGAccount.attribute: error: WMMGAccount.attribute must have a defined type
I've gone into my xcdatamodel, but can't find any attributes that aren't properly defined by type. One suspicious thing I'm seeing is the reference to WMMGDataModel 5. I'm up to version 8 in my model, and can't even find version 5.
This crash began after a recent automatic migration (using MagicalRecord) in which I added an attribute to one of the entities and then recreated the Managed Object Subclass (yes, the new subclass contains the new, properly defined attribute). I've added attributes before, but this is the first time I've encountered this issue.
I've cleaned the thing, quit and restarted Xcode, still crashes. Anybody have any ideas? I also deleted the DerivedData folder for the project. Still won't build.
Edit:
I just recreated all my managed subclass files. Still no dice--same error message.
Edit:
I tried running another project as a control, and got this message:
Unable to run app in Simulator
An error was encountered while running (Domain = FBSOpenApplicationErrorDomain, Code = 4)
So I quit Xcode and the simulator, restarted Xcode. Same error.
Yet more info
I restarted the computer and tried again, but am still getting "Build Failed" with the same error message.
If anyone else has run into anything like this, I sure would appreciate some guidance here... :)
Final edit
Please see solution in my answer below...
Ok, I finally cured the problem with a decision to delete my xcdatamodeld and rebuild the entire model. Some research into how to do this yielded a less destructive and less risky method in this answer.
Here's hoping it will help someone else with this problem.
Thanks to all who took a look!
I've never had the problem you describe, but have a few suggestions. Apologies if you've already tried these:
First, in the model editor, can you access the model version 5 that you suspect is the problem, eg.:
If it's there, you can hopefully fix the attribute error. If it doesn't appear there, have you tried right-click in the Project Navigator and select "Show in Finder":
Then in Finder looking for the version 5?

XCode 6 Framework issue: Module [framework] has no member named [class]

I have built a custom framework that I have pulled into a workspace containing an application I am writing using Xcode 6. I am getting an error when I try to instantiate a class belonging to the framework reading Module 'Framework' has no member named 'Unit':
I have made sure to link the application target to the library created by the framework:
Here is a screenshot of the Unit class:
I have no idea what I'm doing wrong. I don't see anyone else that has experienced this issue. I would be forever indebted to anyone that could help me troubleshoot this issue. Thank you in advance for your help.
I feel very dumb right now. I thought that the default access level was public for everything defined in my Framework. I was able to fix this issue by making the class and the initializer public.

Xcode 6 GM, IB Challenge and Swift

I'm hoping someone can help me or even just let me know that I'm not going out of my mind. I have been searching for an answer to my issue for the past 4 hours and have tried many solutions, none seem to help.
My challenge is that I don't seem to be able to make use of a custom class for a view controller within the GM release of Xcode 6. Here is what I have done.
Begin a new project using File -> New -> Project, selected for an iOS
single view application to start. Once the initial application has
been created, it runs fine within the simulator.
Now I go into my ViewController.swift and change class
ViewController: UIViewController { to class ViewControllerxxx:
UIViewController {
Next, I go into my Main.Storyboard, select the View Controller and
drop down the custom list class where I do not see my custom class.
Now here is where is gets strange.
If I open a project that was created on an earlier beta build of Xcode, the above process works just fine and I see my custom class, just not with newly created projects.
Does anyone else see this behavior, or is it just me?
Hoping someone can shed some light for me...
BTW - manually defining the custom class name doesn't work either - I get a runtime error saying the class is unknown.
Many thanks in advance,
Jon
It would appear that I have fixed it although I have no idea how or why. Basically all of my projects are stored in a folder \Users\jon\code. I renamed the code folder to code.old and then back to code again and for whatever reason, it works now without an issue. I have zero idea as to what caused this issue as nothing in the folder has changed, but the issue is certainly resolved, or at least it appears to be.
So to anyone else experiencing this issue. First try creating a project in a location different to where you are when experiencing the problem. For example, if you are creating your project in Documents, try creating it in the root of your home folder.
If this works, drop to a terminal and using the mv command, rename your projects folder to something else and then back again. After this, I was able to create as many new projects as I wanted, an none had the issue.
Hope this helps someone...

Resources