【发布时间】:2010-10-30 06:59:33
【问题描述】:
我创建了一个静态库来存放我的一些代码,例如类别。
我在“UIView-Extensions.h”中有一个 UIView 类别,名为 Extensions。
在这个类别中,我有一个方法叫做:
- (void)fadeOutWithDelay:(CGFloat)delay duration:(CGFloat)duration;
在调试配置的模拟器上调用此方法可以正常工作。
但是,如果尝试在设备上运行应用程序,我会收到 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
似乎出于某种原因 UIView-Extensions.h 未包含在设备构建中。
我检查过/尝试过的内容
我确实尝试为 NSString 包含另一个类别,但遇到了同样的问题。
其他文件,如整个类和函数都可以正常工作。这是仅类别发生的问题。
我清理了所有目标,但没有解决问题。
我检查了静态库项目,类别包含在目标的“复制标题”和“编译源”组中。
静态库包含在主要项目“将二进制文件与库链接”组中。
另一个我添加了静态库的项目可以正常工作。
我删除并重新添加了静态库,但没有运气
-ObjC 链接器标志已设置
有什么想法吗?
纳米输出
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
【问题讨论】:
-
异常消息具体说了什么?
-
我发现你的这部分问题很有趣
the categories are included in the target's "copy headers" and "compile sources" groups... 通常这些类别不由包含所述静态库的项目调用.. 为什么它应该包含在copy headers部分?苹果在其最近发布的tutorial 中没有提及它 -
正是那个步骤解决了我的问题
标签: iphone cocoa-touch xcode exception