xcode 使用自定义框架时出现“找不到图像”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20092886/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"image not found" Error while using Custom FrameWork
提问by Midhun MP
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:
- 我添加了部署的路径,
Linking
例如:
- 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. - I added the framework under
Link Binary With Libraries
Section - I changed the path of Linking like:
- 我将该框架添加到
FrameWorks
我的项目根目录下的文件夹中。 - 我在
Link Binary With Libraries
节下添加了框架 - 我改变了链接的路径,如:
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
. 它显示的路径如下:
- I followed this link: A Visual Guide to Creating an Embeddable Framework for Mac OSX
But I couldn't fix the issue, yet. Please help me, thanks in advance.
但我还不能解决这个问题。请帮助我,提前致谢。
回答by Parag Bafna
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
. 单击您的目标,然后单击编辑器(菜单栏)-->添加构建阶段-->添加复制文件构建阶段
回答by aToz
I've encountered the same issue and this is how I have solved it,
我遇到了同样的问题,这就是我解决它的方法,
For my case, custom Framework is in Swiftand My project is in Objective c
就我而言,自定义框架在Swift 中,而我的项目在目标 c 中
Follow the following steps,
请按照以下步骤操作,
- Go the Project Navigator
- Select the Targets, go the Generaltab
- Find Embedded Binariesdrag the custom framework. Find the flow
in the below-mentioned image
- Check if the Framework is added to the Linked Frameworks and
Libraries(ref the image)
- NOTE: In my case it was added to Linked Frameworks and Libraries, go a head and removeit
- Last step, find the flag Always embed swift embedded librariesin "Build settings" and turn it to "YES" (ref the image)
- 转到项目导航器
- 选择Targets,转到General选项卡
- Find Embedded Binaries拖动自定义框架。在下面提到的图像中找到流程
- 检查框架是否已添加到链接的框架和库中(参考图片)
- 注意:在我的例子中,它被添加到Linked Frameworks and Libraries,去把它删除
- 最后一步,在“构建设置”中找到标记Always embed swift embedding libraries并将其变为“YES”(参考图片)
I hope this helps.
我希望这有帮助。