IOS static library error "unrecognized selector sent to an instance" - iphone

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.

Related

iOS Framework not able to create object

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.

AdMob [GADObjectPrivate changeState:] error on iOS - NOT able to resolve through -ObjC

After reading many SO posts about the same error, I cant seem to resolve the problem with AdMob.
Im trying to implement it into my existing app and I copied the SDK and followed the tutorial.
All compiles fine but the app crashes with:
[GADObjectPrivate changeState:]: unrecognized selector sent to instance 0xa5cc610'
They say I need to add -ObjC or -all_load to Other Linker Flags.
When I do that, I get many, many duplicate symbol errors.
Since Im upgrading a project from a different developer, I dont know
the exact structure of the code.
Any other suggestions?
When you using the Abmob API, they add 2 API for you. 1 for Debug and 1 for real.
2 API have same functions and many things.
(Try to see what happen in your debug screen, they will give you the location of duplicated folder - It in Google Library 3.0/GoogleAnalysis/Library/lib - ...debug.lib)
The simple solution is remove the Debug API and you will be fine.
Addition: Adding ObjC is right for your program, it is other problem.

How to solve the errror ""_CGAffineTransformMakeRotation", referenced from:"?

When i use the following code i am getting the error message that says
""_CGAffineTransformMakeRotation", referenced from:"
companyNameLbl.transform=CGAffineTransformMakeRotation(30);
Can anyone please tell me what will be the reason for this error.
If I remember correctly, those transformations require that you link against the CoreGraphics Framework.
See How to "add existing frameworks" in Xcode 4? if you have difficulties adding new frameworks in XCode.

Three20's UIKit extensions don't seem to be being "included" properly

So, we have a project using the Three20 Library from Facebook (http://github.com/facebook/three20), and we're trying to compile against the latest version (HEAD from Github).
Previously it's worked fine, but something has now changed :)
The error I'm getting is an unrecognized selector on TTTableViewController:
[TTViewControllerSubClass popupViewController]: unrecognized selector sent to instance
(There's another question about this here)
I checked TTViewController, and it turns out we don't actually need to call popupSubView, so I commented that out. I then get this error:
-[UIImageView removeAllSubviews]: unrecognized selector sent to instance
So, I checked the locations of both these methods in Three20, and they are in UIViewControllerAdditions.m and UIViewAdditions.m, respectively. So this makes me think that Three20 is adding some methods to the basic UIKit classes, and these methods aren't actually getting included the way they should be.
Problem is, I get stuck there :) I've got no clue how to make UIKit include these classes, or "fix" Three20 (if it is indeed a Three20 problem) to make it work.
So I'm hoping some kind soul here will slog through my incredibly long problem description and point me in the right direction!
Thanks in advance :)
Looks like upgrading Three20 and following the instructions at http://three20.info/setup/existing I managed to get this working!

NSConcreteData vs NSData

I have added an extension to NSData (base64 extension), which I kept over a separate infrastructure class lib project. But when i use this method from my main project i am getting an error like this: "-[NSConcreteData encodeBase64]: unrecognized selector sent to instance 0x121e60'".
But if i keep the same class in my main project itself, this will execute with out any issue.
I call this method in the following way:
[dev setToken:[token encodeBase64]];
Please suggest why this is not working if i put the extension in another project. (I am already using some other extensions, eg. for NSDate, like this with out any issue.)
Is this on iPhone OS 3.0? The 3.0 SDK broke the use of -ObjC, but you usually are able to link in categories for a static library by adding the -all_load option to Other Linker Flags within your target application.
The issue is that the metadata necessary to configure a category is usually stripped by the linker because it appears to be dead. If you add the "-ObjC" LDFLAG to your project it will tell the linker to link all the potential ObjC info even if it appears to be dead.