gpt4 book ai didi

objective-c - 我可以在另一个框架中包含一个框架吗?

转载 作者:太空狗 更新时间:2023-10-30 03:32:24 24 4
gpt4 key购买 nike

我正在编写一个框架(称为 Lighthouse.framework),该框架又使用来自另一个框架(准确地说是 RegexKit.framework)的代码。我已经将 RegexKit.framework 复制到我自己的框架中,因此它具有如下结构:

Lighthouse.framework/
Versions/
A/
Frameworks/
RegexKit.framework
Lighthouse

但是,当我尝试运行使用 Lighthouse.framework(我的框架)的应用程序时,出现以下错误:

dyld: Library not loaded: @executable_path/../Frameworks/RegexKit.framework/Versions/A/RegexKit

Referenced from: /Users/mdippery/Developer/Projects/Current/lighthouse/build/Debug/Lighthouse.framework/Versions/A/Lighthouse

Reason: image not found

显然,加载器没有找到 RegexKit。

这是加载器期望加载的路径,由 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)

我可以在另一个框架中包含一个框架吗?这是正确的方法吗?我该如何解决我的错误?

最佳答案

最简单的方法是使用@rpath。您的配置应如下所示:

  1. 设置RegExKit.framework的安装目录为@rpath
  2. 将Lighthouse.frameworks的安装目录设置为@rpath
  3. 将 Lighthouse.framework 的运行路径搜索路径设置为@loader_path/Frameworks
  4. 确保将 RegExKit.framework 复制到 Lighthouse.framework 的 Framework 子文件夹中(为此使用自定义构建阶段)

最后,任何链接到 Lighthouse.framework 的应用程序都应该将 Runpath Search Paths 设置为 @loader_path/../Frameworks

关于objective-c - 我可以在另一个框架中包含一个框架吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3516373/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com