xcode的other linker flag的含义

来源:互联网 发布:手机五彩闪光灯软件 编辑:程序博客网 时间:2024/05/21 23:35

今天编译项目的时候发现抛出了一个异常,<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     加载静态库里面的所有用objc 语言写的类或者扩展类;

-force_load(包的路径)加载指定路径的静态库文件中的所有成员。

所以对于使用runtime时候的反射调用的方法应该使用这三个中的一个进行link,以保证所有的类都可以加载到内存中供程序动态调用


0 0