xcode 尽管 ObjC 标志,“无法识别的选择器发送到实例”到静态库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6034283/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"unrecognized selector sent to instance" to a static library despite ObjC flag
提问by Steven Fisher
I'm getting a runtime error in my application:
我的应用程序出现运行时错误:
2011-05-17 09:42:31.124 rxsync[67464:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSMutableURLRequest setHTTPBodyWithFormMultipartValues:fileNames:contentTypes:usingBoundary:]: unrecognized selector sent to instance 0x4e3cd90'
2011-05-17 09:42:31.124 rxsync[67464:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSMutableURLRequest setHTTPBodyWithFormMultipartValues:fileNames:contentTypes:usingBoundary:]: unrecognized selector sent to instance 0x4e3cd90'
This method, NSMutableURLRequest setHTTPBodyWithFormMultipartValues: fileNames: contentTypes: usingBoundary:]
, is defined by a static library that's part of my .xcworkspace.
此方法NSMutableURLRequest setHTTPBodyWithFormMultipartValues: fileNames: contentTypes: usingBoundary:]
由属于我的 .xcworkspace 的静态库定义。
Here's what I've checked so far:
这是我到目前为止检查过的内容:
- The static library is included in my Link Binary With Librariesphase.
- I have ObjC in the Other Linker Flags (
OTHER_LDFLAGS = -ObjC
) in my application. (In fact, I have it in my static library, too, since it's based on the same xcconfig file.) - The signature is the same in my .h and .m file.
- The static library has definitelybeen rebuilt.
- I have verified that the object I'm sending the message to is valid.
- 静态库包含在我的Link Binary With Libraries阶段。
OTHER_LDFLAGS = -ObjC
我的应用程序的其他链接器标志 ( ) 中有 ObjC 。(事实上,我的静态库中也有它,因为它基于相同的 xcconfig 文件。)- 我的 .h 和 .m 文件中的签名相同。
- 静态库肯定已经重建。
- 我已经验证我发送消息的对象是有效的。
What possibilities am I missing?
我错过了什么可能性?
I'm using Xcode 4.0.2. This is an iPhone target.
我正在使用 Xcode 4.0.2。这是一个 iPhone 目标。
回答by thbonk
You additionally need to add -all_load to the Other Linker Flags of the target which is using your static library.
您还需要将 -all_load 添加到使用静态库的目标的其他链接器标志中。