现在的位置: 首页 > 综合 > 正文

xcode的other linker flag的含义

2013年08月23日 ⁄ 综合 ⁄ 共 830字 ⁄ 字号 评论关闭

原文地址:http://blog.csdn.net/shaobojohn/article/details/7953007

今天编译项目的时候发现抛出了一个异常,<NSInvalidArgumentException>+[NSInvocation invocationWithMethodSignature:]: method signature argumentcannot be nil。但是看到项目里面是有这个类的,最后思考了下,由于是使用的runtime的调用,没有在头文件中import,所以link的时候是找不到这个类的,在网上看了下,只需要在other
linker flag中添加-Objc就可以,添加之后发现正确了,不过感觉还是需要了解下这个编译选项的含义,于是在网络上查了下,最后找个一个英文的解释。

-all_load Loads all members of static archive libraries.

-ObjC Loads all members of static archive libraries that implement an Objective-C class or
category.

-force_load (path_to_archive) Loads all members of the specified static archive library. Note:
-all_load forces all members of all archives to be loaded. This option allows you to target a specific archive.

翻译过来就是-all_load就是会加载静态库文件中的所有成员,-ObjC就是会加载静态库文件中实现一个类或者分类的所有成员,-force_load(包的路径)就是会加载指定路径的静态库文件中的所有成员。所以对于使用runtime时候的反射调用的方法应该使用这三个中的一个进行link,以保证所有的类都可以加载到内存中供程序动态调用

抱歉!评论已关闭.