如何在 Xcode 4 上弱链接框架?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6480765/
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 do I weak link frameworks on Xcode 4?
提问by Quentin Hayot
I need to weak link some framework with my target.
But I can't find how to do it...
我需要将某些框架与我的目标弱链接。
但是我找不到怎么做...
If I try to run my project on 3.2 iPad simulator i get the following error:
如果我尝试在 3.2 iPad 模拟器上运行我的项目,我会收到以下错误:
dyld: Library not loaded: /System/Library/Frameworks/iAd.framework/iAd
Reason : Image not found
Thanks !
谢谢 !
回答by uvesten
Go to your project -> Targets -> Build Phases -> Link Binary with Libraries.
转到您的项目 -> 目标 -> 构建阶段 -> 将二进制文件与库链接。
Then change the library you want to weak-link from "Required" to "Optional".
然后将要弱链接的库从“必需”更改为“可选”。
回答by ronguotech
This doesn't work now. Please follow the link below: https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html
现在这行不通。请点击以下链接:https: //developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html
Select the target you want to modify and reveal its build phases.
选择要修改的目标并显示其构建阶段。
Expand the Link Binary With Libraries build phase to view the frameworks currently linked by the target.
展开 Link Binary With Libraries 构建阶段以查看目标当前链接的框架。
If the framework you want to weakly link to is listed in the Link Binary With Libraries build phase, select it, and choose Edit > Delete to remove it.
如果要弱链接的框架在 Link Binary With Libraries 构建阶段中列出,请选择它,然后选择“编辑”>“删除”将其删除。
Now you can tell the linker to use weak linking for that framework.
现在您可以告诉链接器对该框架使用弱链接。
Select the target, open its Info window, and click Build.
选择目标,打开其信息窗口,然后单击构建。
To the Other Linker Flags build setting, add the following command-line option specification, where is the name of the framework you want to weakly link to: -weak_framework
在其他链接器标志构建设置中,添加以下命令行选项规范,其中是您要弱链接到的框架的名称:-weak_framework
Build your product.
构建您的产品。