Can I include a framework in another framework?(我可以在另一个框架中包含一个框架吗?)
问题描述
我正在编写一个框架(称为 Lighthouse.framework),该框架又使用来自另一个框架(准确地说是 RegexKit.framework)的代码.我已将 RegexKit.framework 复制到我自己的框架中,使其具有如下结构:
I'm writing a framework (called Lighthouse.framework) that, in turn, uses code from another framework (RegexKit.framework, to be precise). I have copied RegexKit.framework into my own framework, so that it has a structure like the following:
Lighthouse.framework/
Versions/
A/
Frameworks/
RegexKit.framework
Lighthouse
但是,当我尝试运行使用 Lighthouse.framework(我的框架)的应用程序时,我收到以下错误:
However, when I try to run an application that uses Lighthouse.framework (my framework), I get the following error:
dyld:库未加载:@executable_path/../Frameworks/RegexKit.framework/Versions/A/RegexKit
dyld: Library not loaded: @executable_path/../Frameworks/RegexKit.framework/Versions/A/RegexKit
引用自:/Users/mdippery/Developer/Projects/Current/lighthouse/build/Debug/Lighthouse.framework/Versions/A/Lighthouse
Referenced from: /Users/mdippery/Developer/Projects/Current/lighthouse/build/Debug/Lighthouse.framework/Versions/A/Lighthouse
原因:图片未找到
显然,加载程序没有找到 RegexKit.
Obviously, the loader isn't finding RegexKit.
这是加载器期望加载的路径,由 otool
提供:
Here're the paths the loader expects to load, courtesy otool
:
build/Debug/Lighthouse.framework/Versions/A/Lighthouse:
/Users/mdippery/Library/Frameworks/Lighthouse.framework/Versions/A/Lighthouse (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 12.0.0)
@executable_path/../Frameworks/RegexKit.framework/Versions/A/RegexKit (compatibility version 0.4.0, current version 0.6.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.4)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 227.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 476.19.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 677.26.0)
我可以在另一个框架中包含一个框架吗?这是正确的方法吗?如何解决我的错误?
Can I include a framework in another framework? Is this the proper way to do it? How can I resolve my error?
推荐答案
我找到了解决这个问题的方法.我从 sbooth 的回答中吸收了一些想法,但修复更简单.我运行了这个脚本:
I discovered a fix for this problem. I incorporated some ideas from sbooth's answer, but the fix was simpler. I ran this script:
install_name_tool -change @executable_path/../Frameworks/RegexKit.framework/Versions/A/RegexKit @loader_path/Frameworks/RegexKit.framework/Versions/A/RegexKit "${TARGET_BUILD_DIR}/${PRODUCT_NAME}.framework/Versions/A/${PRODUCT_NAME}"
作为运行构建脚本阶段.
as a Run Build Script phase.
注意,对于一般情况,您必须将@executable_path/../
更改为@loader_path/
,一切正常.
Note that, for the general case, you have to change @executable_path/../
to @loader_path/
, and all is well.
这篇关于我可以在另一个框架中包含一个框架吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我可以在另一个框架中包含一个框架吗?
基础教程推荐
- 更改 UITableView 部分标题的颜色 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- UINavigationItem 的持久 rightBarButtonItem 属性 2022-01-01
- Firebase 云消息传递令牌未生成 2022-01-01
- 在视图控制器的宽度上水平均匀分布 UIButton 的最简单方法? 2022-01-01
- 在 iOS 7 下 CCMenu 错位 2022-01-01
- 从 UIWebView 访问元数据 2022-01-01
- UINavigationBar 隐藏按钮文本 2022-01-01
- Android - 如何在runOnUiThread 中将数据传递给Runnable? 2022-01-01
- EditText 中的 setHintTextColor() 2022-01-01