I have created a iOS framework in which I only have a UIView Class (let say X) in which I have declared some datasource and delegate methods.
Now when I am using the framework in a project and try to create a object of X, it gives me following error:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_X", referenced from:
objc-class-ref in ViewController.o
Now if I take a UIView in XIB and change its class to X and connect it to an outlet and then setDelegate and setDatasource it throws an exception:
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[UIView setDataSource:]: unrecognized selector sent to instance 0x756f670
if I don't do the above two steps. it builds and runs fine.
I hope I am clear with question. Thanks for any help in advance.
As for 1:
The reason is that the framework is not built for the iPhone Simulator. I had a similar issue with CocosDenshion, documented in this SO Question of mine (someone didn't like it though, for some reason).
The easiest solution is put your project and your framework into an Xcode Workspace and Xcode will build the framework for the iPhone Simulator as and when required. If you don't want to do that then follow the instructions in the SO question linked above.
As for 2:
You need to provide the methods specified; it looks like you changed a UITableView-based class and changed it to a UIView-based class, which won't work. Derive the new class from UITableView and things should start rolling again.
Related
The current app I have been working on has been running fine with no issues and suddenly, what seems like out of the blue as I hadn't made any changes, crashes at launch with an NSInvalidUnarchiveOperationException.
I made zero code changes and the only thing I did was to run the app on my Mac to see how it would look on MacOS. I then ran it again on my iPhone and that's when the problem started to occur. I use CoreData and CloudKit so decided to delete all data to see if that would solve the issue (not thinking it would based on the console log) and it still crashes.
The console states the following:
Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: '*** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (NSFontDescriptor) for key (UIFontDescriptor) because no class named "NSFontDescriptor" was found; the class needs to be defined in source code or linked in from a library (ensure the class is part of the correct target). If the class was renamed, use setClassName:forClass: to add a class translation mapping to NSKeyedUnarchiver'
The thing is, although I use attributed strings I clearly haven't created a class named NSFontDescriptor. NSFontDescriptor is part of the SDK so I have no idea what's going on and how to fix this issue.
Any help would be much appreciated.
i got some problem when i trying to include framework within framework. i try to make subframework in swift language. when i run in simulator work perfectly but in device i have error “Reason: no suitable image found. Did find:”
the following is an error message:
dyld: Library not loaded: #rpath/xxx.framework/xxx Referenced from:
/private/var/containers/Bundle/Application/81D1C716-915E-4DCA-893D-F934D56C8BAD/customDemo.app/Frameworks/custom.framework/custom
Reason: no suitable image found. Did find:
/private/var/containers/Bundle/Application/81D1C716-915E-4DCA-893D-F934D56C8BAD/customDemo.app/Frameworks/custom.framework/Frameworks/xxx.framework/xxx:
mmap() error 1 at address=0x00169000, size=0x000E8000 segment=__TEXT
in Segment::map() mapping
/private/var/containers/Bundle/Application/81D1C716-915E-4DCA-893D-F934D56C8BAD/customDemo.app/Frameworks/custom.framework/Frameworks/xxx.framework/xxx
You are not allowed to submit an app to the App Store with a framework embedded inside another framework. All frameworks must be inside the main app bundle's Frameworks folder. This does not mean you cannot link one framework against another, though. Just specify framework B inside framework A's Link Binary With Libraries build phase, and don't embed it.
I had a perfectly working app. I wanted to modularize my app because I envision needing bits and pieces of it in other apps. So, I created two frameworks. The two frameworks build fine and my app with the two frameworks embedded in it also builds fine.
My problem comes when I try to unarchive data which has a class that is now in one of my frameworks. I get this error:
reason: '*** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (myProjecy.MyObject) for key (NS.objects); the class may be defined in source code or a library that is not linked'
In my app I can create instances MyObject fine. All the required methods in the framework are either open or public (or the app wouldn't even build).
What an I missing?
The class in the framework is in Swift and the class trying to unarchive it in is Obj-C. I'm using Xcode 9.
Thanks.
OK. I found the problem. Re-visiting this post led me to a solution.
In my case, because the original object was archived while still part of the app and my app specified to use module name then the object was archived with the app's module name. Now, the unarchiver is trying to use the module name in the framework which is what leads to the problem.
So, I basically had to sprinkle a few of these:
NSKeyedUnarchiver.setClass(ClassName.self, forClassName: "AppModule.ClassName")
NSKeyedArchiver.setClassName("AppModule.ClassName", for: ClassName.self)
And everything works fine!
Without this code the the unarchiver tries to use "FrameworkModule.ClassName".
I have created the static library which compiles successfully,I have added .a file in the application where I want to use it. But getting the error "unrecognised selector sent to an instance". But if I include the static library source in the application I am not getting any error. can someone help me in this issue.
Maybe the selector is implemented in a category and you’re missing the -ObjC linker flag? See the Apple Technical QA1490.
Hi my application runs fine but when I try to run the unit tests I am getting this error...
2010-10-19 00:27:49.919 AssignmentUnitTest[27988:903] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'*** -[NSURL initFileURLWithPath:]: nil string parameter'
Irony is I have searched the whole project & I dont have any similar line of code that uses **[NSURL initFileURLWithPath:]**
I have pretty much wasted half of my day on it without any success.
I am using coredata in the project & below is the screen shot with stack trace.
Can anyone please guide me to the right direction.
Thanks
**EDIt : ** The solution to this problem is to add not only the .xcdatamodel file but the root file .xcdatamodeld. Core Data was having trouble finding my model so was displaying this error. Hope it helps somebody someday.
Read the call stack in your screenshot. It says your managedObjectModel method sent [NSURL fileURLWithPath:], and that called initFileURLWithPath:. So, find the point where you sent [NSURL fileURLWithPath:] and fix your argument to that message.
The argument you passed being invalid suggests that either you passed nil for the path (perhaps you tried to find the file in your bundle but it isn't there or has a different name than you looked for), or you passed a pointer to an object that isn't a string (perhaps you had a string but under-retained it and a different object was created in its place).
There is a bug in some version(s) of the SDK that broke exception handling in the simulator.
Can you run the tests on a device?