静态iOS库中无法识别的选择器调用类别方法 [英] Unrecognized selector calling category method in static iOS library

查看:55
本文介绍了静态iOS库中无法识别的选择器调用类别方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一些第三方软件来帮助使用Xcode 4.3.2编写iPad应用程序.该软件是开源的,通常已设置好,因此它将与开发人员为应用程序编写的任何代码一起编译其代码.因为我在许多地方都在使用该软件,所以我决定将其构建为iOS模拟器的静态库.

I am using some third party software to aid in writing an iPad application using Xcode 4.3.2. The software is open source and is usually set up so its code will be compiled along with whatever code the developer writes for the application. Because I was using the software in numerous places, I decided to build it as a static library for the iOS simulator.

我能够构建该库,并转换一个应用程序以链接到该库,而不用编译原始源代码.但是,当我在模拟器上运行应用程序时,出现错误消息,无法识别的选择器发送到实例.

I was able to build the library, and convert one application to link to that library instead of compiling the original source code. However, when I go to run the application on the simulator, I get an error that says, unrecognized selector sent to instance.

我已验证该程序已成功使用静态库的某些部分.但是,有一段代码试图在对象上调用方法,并且该代码在发生故障的地方发生.实际在该对象的接口中未定义要调用的方法.而是在一个附加模块中提供该模块,该模块为该对象的类定义了一个类别.正确包含了该模块的头文件,并且编译器应该已经能够找到category方法并将其应用于对象,但是在运行时,会发生上述错误.

I have verified that the program is successfully using portions of the static library. However, there is one piece of code that tries to call a method on an object, and that where the failure occurs. The method being called is not actually defined in the interface of that object. Rather it is provided in an additional module that defines a category for that object's class. The header file for that module is properly included and the compiler should have been able to find the category method and apply it to the object, yet at run time, the error mentioned above occurs.

我使用了'nm'命令来验证类别方法在静态库中是否存在.这是输出示例:

I used the 'nm' command to verify that the category method exists in the static library. Here is an example of the output:

nm libStaticLibrary.a | grep categoryMethod
00000130 t -[SomeClass(Category) categoryMethod:]
0000354c s -[SomeClass(Category) categoryMethod:].eh

人们对如何使该库与所需的应用程序正确工作有什么想法?

What ideas do people have about how this library can be made to work correctly with the desired application?

推荐答案

您的第三方框架可能使用现有(苹果)类上的类别.但是要加载/查找类别,您需要在构建设置中的 Other Linker Flags

Your 3rd party framework is probable using a category on a existing (apple) class. But to load/find the category you need to add the -ObjC flag in the build settings under Other Linker Flags

这篇关于静态iOS库中无法识别的选择器调用类别方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆