Google Admob for iOS SDK中静态库在加载过程中,如果不在Build Settings中添加other link 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,以保证所有的类都可以加载到内存中供程序动态调用。