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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 21:03:02  来源:igfitidea点击:

"unrecognized selector sent to instance" to a static library despite ObjC flag

xcodestatic-libraries

提问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:

这是我到目前为止检查过的内容:

  1. The static library is included in my Link Binary With Librariesphase.
  2. 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.)
  3. The signature is the same in my .h and .m file.
  4. The static library has definitelybeen rebuilt.
  5. I have verified that the object I'm sending the message to is valid.
  1. 静态库包含在我的Link Binary With Libraries阶段。
  2. OTHER_LDFLAGS = -ObjC我的应用程序的其他链接器标志 ( ) 中有 ObjC 。(事实上​​,我的静态库中也有它,因为它基于相同的 xcconfig 文件。)
  3. 我的 .h 和 .m 文件中的签名相同。
  4. 静态库肯定已经重建。
  5. 我已经验证我发送消息的对象是有效的。

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 添加到使用静态库的目标的其他链接器标志中。