“找不到图像”使用自定义框架时出错

时间:2022-10-10 12:24:59

I created my own framework for one of my cocoa application. I added that framework to my project and called a method from that framework. When I tried to run my application it crashed:

我为我的一个可可应用程序创建了自己的框架。我将该框架添加到我的项目中并从该框架调用了一个方法。当我试图运行我的应用程序时,它崩溃了:

Crash Log:

dyld: Library not loaded: @rpath/MMP.framework/Versions/A/MMP
  Referenced from: /Users/Midhun/Library/Developer/Xcode/DerivedData/MMPTest-ccvjtgedqkcftchapjehhwjbaqdq/Build/Products/Debug/MMPTest.app/Contents/MacOS/MMPTest
  Reason: image not found

What I have done:

FrameWork:

  • I added my header file in public section
  • 我在公共部分添加了我的头文件

“找不到图像”使用自定义框架时出错

  • I added the paths of Deployment and Linking like:
  • 我添加了部署和链接的路径,如:

“找不到图像”使用自定义框架时出错

  • I build the project and I got my framework ready (Pretty cool till here).
  • 我构建了这个项目,并准备好了我的框架(直到这里很酷)。

Project:

  • I added that framework to FrameWorks folder under my Project's root directory.
  • 我将该框架添加到Project的根目录下的FrameWorks文件夹中。

  • I added the framework under Link Binary With Libraries Section
  • 我在Link Binary With Libraries Section下添加了框架

  • I changed the path of Linking like: “找不到图像”使用自定义框架时出错
  • 我改变了Linking的路径:

Platform Details:

Xcode: 4.6.2
OS X : 10.8

What I have tried (After the crash)

我尝试了什么(崩溃后)

  • When I get this issue, I checked with otool. It shows the paths like:
  • 当我遇到这个问题时,我检查了otool。它显示了以下路径:

“找不到图像”使用自定义框架时出错

But I couldn't fix the issue, yet. Please help me, thanks in advance.

但我无法解决这个问题。请帮助我,提前谢谢。

2 个解决方案

#1


25  

Set framework installation directory to @executable_path/../Frameworks

将框架安装目录设置为@executable_path /../ Frameworks

“找不到图像”使用自定义框架时出错

Now add copy files in your build phase, set destination to Frameworks. click on your target, then on Editor (menu bar) --> Add build phase --> Add Copy Files Build Phase

现在在构建阶段添加复制文件,将目标设置为Frameworks。单击目标,然后单击编辑器(菜单栏) - >添加构建阶段 - >添加复制文件构建阶段

“找不到图像”使用自定义框架时出错

“找不到图像”使用自定义框架时出错

#2


4  

I've encountered the same issue and this is how I have solved it,

我遇到了同样的问题,这就是我解决它的方法,

For my case, custom Framework is in Swift and My project is in Objective c

对于我的情况,自定义框架在Swift中,我的项目在Objective c中

Follow the following steps,

请按照以下步骤操作

  1. Go the Project Navigator
  2. 转到Project Navigator

  3. Select the Targets, go the General tab
  4. 选择目标,转到常规选项卡

  5. Find Embedded Binaries drag the custom framework. Find the flow in the below-mentioned image“找不到图像”使用自定义框架时出错
  6. 查找嵌入式二进制文件拖动自定义框架。在下面提到的图像中找到流程

  7. Check if the Framework is added to the Linked Frameworks and Libraries (ref the image)“找不到图像”使用自定义框架时出错
  8. 检查框架是否已添加到链接的框架和库(参考图像)

  9. NOTE: In my case it was added to Linked Frameworks and Libraries, go a head and remove it
  10. 注意:在我的情况下,它被添加到链接框架和库,去头并删除它

  11. Last step, find the flag Always embed swift embedded librariesin "Build settings" and turn it to "YES" (ref the image)
  12. 最后一步,在“Build settings”中找到标记Always embed swift embedded libraries并将其转为“YES”(参考图像)

“找不到图像”使用自定义框架时出错

I hope this helps.

我希望这有帮助。

#1


25  

Set framework installation directory to @executable_path/../Frameworks

将框架安装目录设置为@executable_path /../ Frameworks

“找不到图像”使用自定义框架时出错

Now add copy files in your build phase, set destination to Frameworks. click on your target, then on Editor (menu bar) --> Add build phase --> Add Copy Files Build Phase

现在在构建阶段添加复制文件,将目标设置为Frameworks。单击目标,然后单击编辑器(菜单栏) - >添加构建阶段 - >添加复制文件构建阶段

“找不到图像”使用自定义框架时出错

“找不到图像”使用自定义框架时出错

#2


4  

I've encountered the same issue and this is how I have solved it,

我遇到了同样的问题,这就是我解决它的方法,

For my case, custom Framework is in Swift and My project is in Objective c

对于我的情况,自定义框架在Swift中,我的项目在Objective c中

Follow the following steps,

请按照以下步骤操作

  1. Go the Project Navigator
  2. 转到Project Navigator

  3. Select the Targets, go the General tab
  4. 选择目标,转到常规选项卡

  5. Find Embedded Binaries drag the custom framework. Find the flow in the below-mentioned image“找不到图像”使用自定义框架时出错
  6. 查找嵌入式二进制文件拖动自定义框架。在下面提到的图像中找到流程

  7. Check if the Framework is added to the Linked Frameworks and Libraries (ref the image)“找不到图像”使用自定义框架时出错
  8. 检查框架是否已添加到链接的框架和库(参考图像)

  9. NOTE: In my case it was added to Linked Frameworks and Libraries, go a head and remove it
  10. 注意:在我的情况下,它被添加到链接框架和库,去头并删除它

  11. Last step, find the flag Always embed swift embedded librariesin "Build settings" and turn it to "YES" (ref the image)
  12. 最后一步,在“Build settings”中找到标记Always embed swift embedded libraries并将其转为“YES”(参考图像)

“找不到图像”使用自定义框架时出错

I hope this helps.

我希望这有帮助。