如何在 Xcode 中将库与“-force_load”链接?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31580245/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to link the library with "-force_load" in Xcode?
提问by RJ168
My other libraries not allow me to set -ObjC or all_load flags. So I need to use -force_load to link my library.
我的其他库不允许我设置 -ObjC 或 all_load 标志。所以我需要使用 -force_load 来链接我的库。
I have "GoogleOpenSource.framework" & "GooglePlus.framework" under my project, so how can I map those correctly to work.
我的项目下有“GoogleOpenSource.framework”和“GooglePlus.framework”,所以我如何正确映射它们才能工作。
I have set paths like this:
我已经设置了这样的路径:
-force_load $(PROJECT_DIR)/Project_name/GooglePlus.framework/Versions/A/Headers/GooglePlus.h
-force_load $(PROJECT_DIR)/Project_name/GoogleOpenSource.framework/Versions/A/Headers/GoogleOpenSource.h
under the Other linker flags, but it's not working.
在其他链接器标志下,但它不起作用。
What am I doing wrong here?
我在这里做错了什么?
采纳答案by Amit Thakur
I faced the same issue, but finally i fixed this by below mentioned steps:-
我遇到了同样的问题,但最后我通过以下提到的步骤解决了这个问题:-
Steps
脚步
- Go to the "other linker flags" inside your project's build settings and then
- Add
-force_load $(PROJECT_DIR)/yourframewokname.framework/yourframeworkname
- 转到项目构建设置中的“其他链接器标志”,然后
- 添加
-force_load $(PROJECT_DIR)/yourframewokname.framework/yourframeworkname
Note** The framework which requires to add -ObjC flag inside the other linker flag in that case it conflicts with other libraries so in this case you need to force load the library which requires -ObjC.
注意** 需要在其他链接器标志中添加 -ObjC 标志的框架,在这种情况下它与其他库冲突,因此在这种情况下,您需要强制加载需要 -ObjC 的库。
Use above mentioned steps it works.
使用上面提到的步骤就可以了。
回答by technophyle
-force_load
flag is for loading static libraries, so you put the library archive, NOTthe header file as the parameter.
-force_load
标志用于加载静态库,因此您将库存档而不是头文件作为参数。
Use the following instead:
请改用以下内容:
-force_load GooglePlus.framework/Versions/Current/GooglePlus
-force_load GoogleOpenSource.framework/Versions/Current/GoogleOpenSource