-ObjC标志可以选择性地应用于静态库吗? [英] Can the -ObjC flag be applied selectively to static libraries?

查看:170
本文介绍了-ObjC标志可以选择性地应用于静态库吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TL; DR



如何使 -ObjC 链接器标志定位一个特定的静态库,而不是所有我链接的静态库,以避免与我的应用程序链接的未使用的对象文件?






太长;阅读



所以,您正在开发一个新的iOS应用程序,并添加到本地生成的objcutil静态库中,其中包含各种有用的Objective-C类(未实施为类别)做各种过去有用的事情。到目前为止,这么好,只有在实用程序库中引用的那些目标文件正在与应用程序链接。



然后你决定整合 Google Maps SDK ,希望您使用 -ObjC 其他链接器标志,并且实用程序库中的所有突然依赖关系无法解析,因为您尚未配置Xcode链接到这些库。



OK我可以很容易地解决缺少的依赖项,但是现在你不需要使用未使用的对象文件和库依赖关系,而且你想要比这更简洁。 p>

那么你如何避免OCD超载?





ld 联机帮助页:


-ObjC 加载静态存档的所有成员定义Objec的库C级或类别。此选项不适用于动态
共享库。








  • Xcode版本:5.1.1

  • OSX版本:10.9.4


解决方案

确定,所以答案是使用 -force_load 而不是 -ObjC 因为 -force_load 更为重点。



所以WRT到Google Maps SDK,如果你按照说明和复制将静态框架放入app项目目录中,然后框架将在项目根目录下,您可以从删除 -ObjC 其他链接器标志并将其替换为



-force_load GoogleMaps.framework / Versions / Current / GoogleMaps





没有其他需要更改。



对于其他库,您将需要使用完整的sta tic库路径作为 -force_load 的参数。


TL;DR

How can I make the -ObjC linker flag target a specific static library and not all the static libraries I am linking against in order to avoid unused object files being linked in with my app?


Too Long; Did Read

So you are developing a new iOS app and you add in your homegrown "objcutil" static library which contains a variety of useful Objective-C classes (not implemented as categories) to do various things that have been useful in the past. So far, so good, and only those object files that are being referenced in the utility library are being linked with the app.

Then you decide to integrate the Google Maps SDK which wants you to use the -ObjC Other Linker Flags and all of a sudden dependencies in the utility library fail to be resolved, because you haven't configured Xcode to link to those libraries.

OK I can resolve the missing dependencies easily enough, however you now have unused object files and library dependencies that you don't need and you'd like to be a bit tidier than that.

So how do you avoid OCD overload?


Some reference from the ld manpage:

-ObjC Loads all members of static archive libraries that define an Objective C class or a category. This option does not apply to dynamic shared libraries.


  • Xcode Version: 5.1.1
  • OSX Version: 10.9.4

解决方案

OK so the answer is to use -force_load instead of -ObjC as -force_load is more focused.

So WRT to the Google Maps SDK, if you followed the instructions and copied the static framework into the app project directory, then the framework will be in the project root directory and you can remove -ObjC from the Other Linker Flags and replace it with

-force_load GoogleMaps.framework/Versions/Current/GoogleMaps:

Nothing else needs changing.

For other libraries you will need to use the full static library path as the argument to -force_load.

这篇关于-ObjC标志可以选择性地应用于静态库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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