kstenerud / iOS-Universal-Framework

An XCode project template to build universal frameworks (arm7, arm7s, and simulator) for iOS / iPhone.
2.94k stars 473 forks source link

unrecognized selector when class is extended #68

Open gilad-xtify opened 12 years ago

gilad-xtify commented 12 years ago

Hi, Thanks for your work.

I am using the beta version and I am getting a run time error unrecognized selector... when the file name used is of the notation ClassName+Method. I didn't have the problem in the previous version. I like to use the beta version since it resolve some warnings I previously had.

For example if I use a file name NSObject+SBJson and then referring to a method in that class, for example: [__NSCFString JSONValue], I'm getting the unrecognized selector error.

Is that a know issue? is there a work around? Thanks,

kstenerud commented 12 years ago

You'll get unrecognized selector errors when calling category code if the code author didn't put in a fake class inside the category source file. You can either add one yourself or just add -all_load to the linker flags in your final app target.

gilad-xtify commented 12 years ago

I made the changes documented in 'Unrecognized selector in (some class with a category method)' https://github.com/kstenerud/iOS-Universal-Framework#unrecognized-selector-in-some-class-with-a-category-method

However, it only works when I added "-ObjC" to the "Other Linker Flags" in build setting for the project that uses the framework.

Is there a way to change the category source file in a way that I won't need to add the linker flag?

On Mon, Jun 4, 2012 at 11:57 AM, Karl Stenerud < reply@reply.github.com

wrote:

You'll get unrecognized selector errors when calling category code if the code author didn't put in a fake class inside the category source file. You can either add one yourself or just add -all_load to the linker flags in your final app target.


Reply to this email directly or view it on GitHub:

https://github.com/kstenerud/iOS-Universal-Framework/issues/68#issuecomment-6102616

-Gilad

kstenerud commented 12 years ago

Unfortunately, no. The fake class trick allows you to avoid -all_load at least, but the linker won't link in category code if you don't put -ObjC in your linker flags (the same happens with static libraries). This is a compiler/linker issue that has been broken for a long time. You should bug Apple and the CLANG/LLVM crew to fix it.