如何在 Xcode 4 上弱链接框架?
我需要将一些框架与我的目标弱链接。
但我找不到如何做到这一点...
如果我尝试在 3.2 iPad 模拟器上运行我的项目,我会收到以下错误:
dyld: Library not loaded: /System/Library/Frameworks/iAd.framework/iAd
Reason : Image not found
谢谢!
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:
dyld: Library not loaded: /System/Library/Frameworks/iAd.framework/iAd
Reason : Image not found
Thanks !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
转到您的项目 ->目标->构建阶段 ->将二进制文件与库链接。
然后将要弱链接的库从“必需”更改为“可选”。
Go to your project -> Targets -> Build Phases -> Link Binary with Libraries.
Then change the library you want to weak-link from "Required" to "Optional".
现在这行不通了。请点击以下链接:
https://developer.apple.com/ Library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html
选择要修改的目标并显示其构建阶段。
展开 Link Binary With Libraries 构建阶段以查看目标当前链接的框架。
如果要弱链接到的框架在 Link Binary With Libraries 构建阶段中列出,请选择它,然后选择 Edit >删除即可将其删除。
现在您可以告诉链接器对该框架使用弱链接。
选择目标,打开其信息窗口,然后单击构建。
在“其他链接器标志”构建设置中,添加以下命令行选项规范,其中 FRAMEWORK_NAME 是要弱链接到的框架的名称:
-weak_framework FRAMEWORK_NAME
构建您的产品。
This doesn't work now. Please follow the link below:
https://developer.apple.com/library/archive/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.
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.
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 FRAMEWORK_NAME is the name of the framework you want to weakly link to:
-weak_framework FRAMEWORK_NAME
Build your product.