“unrecognized selector sent to instance” to a static library despite ObjC flag

南楼画角 提交于 2019-12-30 01:53:05

问题


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'

This method, NSMutableURLRequest setHTTPBodyWithFormMultipartValues: fileNames: contentTypes: usingBoundary:], is defined by a static library that's part of my .xcworkspace.

Here's what I've checked so far:

  1. The static library is included in my Link Binary With Libraries phase.
  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 definitely been rebuilt.
  5. I have verified that the object I'm sending the message to is valid.

What possibilities am I missing?

I'm using Xcode 4.0.2. This is an iPhone target.


回答1:


You additionally need to add -all_load to the Other Linker Flags of the target which is using your static library.



来源:https://stackoverflow.com/questions/6034283/unrecognized-selector-sent-to-instance-to-a-static-library-despite-objc-flag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!