未加载 OS X 框架库:“找不到图像" [英] OS X Framework Library not loaded: 'Image not found'

查看:37
本文介绍了未加载 OS X 框架库:“找不到图像"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个基本的 OS X 框架,现在我只创建了一个测试框架:TestMacFramework.framework,我正在尝试将它导入到一个全新的 OS X 应用程序项目中.

I am trying to create a basic OS X Framework, right now I just have a test framework created: TestMacFramework.framework and I'm trying to import it into a brand new OS X Application project.

我已经构建了 .framework 文件并将其导入到新项目中,该框架似乎链接正常,我可以引用我添加到框架构建阶段部分的公共头文件.

I have built the .framework file and imported it into the new project, The framework appears to link okay, and I can reference the public header file I added to the framework build phases section.

但是,当我尝试运行容器应用程序时,出现以下错误:

However, when I try to run the container Application I get the following Error:

dyld: Library not loaded: /Library/Frameworks/TestMacFramework.framework/Versions/A/TestMacFramework
  Referenced from: /Users/samharman/Library/Developer/Xcode/DerivedData/TestMacContainer-dzabuelobzfknafuhmgooqhqrgzl/Build/Products/Debug/TestMacContainer.app/Contents/MacOS/TestMacContainer
  Reason: image not found

经过一番谷歌搜索后,我意识到我需要在我的容器应用程序构建阶段添加一个 Copy Files 部分,所以我已经这样做了并像这样设置...

After a bit of googling I realised I needed to add a Copy Files section to my container application build phases, so I have done this and set it up like so...

但是,我仍然收到运行时错误.我显然在这里做错了什么,但是这个 Apple 开发人员库资源引用了 Xcode 2,所以不是很有帮助!

However, I am still getting the runtime error. I'm obviously doing something wrong here, but the Apple developer library resource for this references Xcode 2, so isn't very helpful!

我错过了什么?

更新:

我可以在构建日志中看到我的 TestMacFramework.framework 正在被复制到 .app contents/frameworks 目录中,但它没有安装到 HD 上的 Library/Frameworks 目录中

I can see in the build log that my TestMacFramework.framework is being copied into the .app contents/frameworks directory, but it isn't being installed to the Library/Frameworks directory on the HD

更新 2:

如果我手动将 TestMacFramework.framework 复制到 Library/Frameworks 目录中,构建链接正确

The build links correctly if I manually copy the TestMacFramework.framework into the Library/Frameworks directory

推荐答案

[Xcode 11+]

唯一要做的就是将框架添加到应用目标的 General 选项卡中的 General->Frameworks, Libraries And Embedded Content 部分.

The only thing to do is to add the framework to the General->Frameworks, Libraries And Embedded Content section in the General tab of your app target.

确保您选择了嵌入 &签名"选项.

Make sure you select the 'Embed & Sign' option.

[Xcode v6 -> Xcode v10]

唯一要做的就是将框架添加到应用目标的 General 选项卡中的 Embedded binaries 部分.

The only thing to do is to add the framework to the Embedded binaries section in the General tab of your app target.

这篇关于未加载 OS X 框架库:“找不到图像"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆