Calling method on category included from iPhone static library causes NSInvalidArgumentException

Posted by Corey Floyd on Stack Overflow See other posts from Stack Overflow or by Corey Floyd
Published on 2009-05-31T21:01:23Z Indexed on 2010/03/24 3:43 UTC
Read the original article Hit count: 337

I have created a static library to house some of my code like categories.

I have a category for UIViews in "UIView-Extensions.h" named Extensions.

In this category I have a method called:

- (void)fadeOutWithDelay:(CGFloat)delay duration:(CGFloat)duration;

Calling this method works fine on the simulator on Debug configuration.

However, if try to run the app on the device I get a NSInvalidArgumentException:

[UIView fadeOutWithDelay:duration:]: unrecognized selector sent to instance 0x1912b0
 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIView fadeOutWithDelay:duration:]: unrecognized selector sent to instance 0x1912b0

It seems for some reason UIView-Extensions.h is not being included in the device builds.


What I have checked/tried

I did try to include another category for NSString, and had the same issue.

Other files, like whole classes and functions work fine. It is an issue that only happens with categories.

I did a clean all targets, which did not fix the problem.

I checked the static library project, the categories are included in the target's "copy headers" and "compile sources" groups.

The static library is included in the main projects "link binary with library" group.

Another project I have added the static library to works just fine.

I deleted and re-added the static library with no luck

-ObjC linker flag is set

Any ideas?


nm output

libFJSCodeDebug.a(UIView-Extensions.o):
000004d4 t -[UIView(Extensions) changeColor:withDelay:duration:]
00000000 t -[UIView(Extensions) fadeInWithDelay:duration:]
000000dc t -[UIView(Extensions) fadeOutWithDelay:duration:]
00000abc t -[UIView(Extensions) firstResponder]
000006b0 t -[UIView(Extensions) hasSubviewOfClass:]
00000870 t -[UIView(Extensions) hasSubviewOfClass:thatContainsPoint:]
000005cc t -[UIView(Extensions) rotate:]
000002d8 t -[UIView(Extensions) shrinkToSize:withDelay:duration:]
000001b8 t -[UIView(Extensions) translateToFrame:delay:duration:]
         U _CGAffineTransformRotate
000004a8 t _CGPointMake
         U _CGRectContainsPoint
         U _NSLog
         U _OBJC_CLASS_$_UIColor
         U _OBJC_CLASS_$_UIView
         U ___CFConstantStringClassReference
         U ___addsf3vfp
         U ___divdf3vfp
         U ___divsf3vfp
         U ___extendsfdf2vfp
         U ___muldf3vfp
         U ___truncdfsf2vfp
         U _objc_enumerationMutation
         U _objc_msgSend
         U _objc_msgSend_stret
         U dyld_stub_binding_helper

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk