在XCode中绑定带有应用程序的框架 [英] Bundle framework with application in XCode

查看:63
本文介绍了在XCode中绑定带有应用程序的框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是XCode新手。我正在尝试遵循这些说明。显然我错过了一些东西,因为虽然我可以看到我想要的框架已被复制到应用程序包中,但我无法引用它。



当我从非我的机器启动应用程序时(或者如果我从/ Library / Frameworks /删除OpenCV)时,出现以下错误:


Dyld错误消息:库没有加载

/Users/david/Library/Frameworks/OpenCV.framework/Versions/A/ OpenCV
引用自:
/Users/g/Demo/Slates/ClipSplitter/build/Release/ClipSplitter.app/Contents/MacOS/ClipSplitter
原因:image not found


如果我的系统中没有用户david,如果这有什么区别的话。这也是从互联网下载的预构建的OpenCV。 (根据评论的要求,这是该项目的屏幕截图)。

解决方案

当OpenCV.framework被构建时,它已被配置为使用 / Users / david / Library / Frameworks /



因为您想将库用作私有框架(安装在 ClipSplitter.app/Contents/Frameworks/OpenCV.framework ),您必须更改其安装路径。这可以通过终端轻松完成,如下所示:

  $ install_name_tool -id @executable_path /../ Frameworks / OpenCV.framework / OpenCV< your_path> /OpenCV.framework/OpenCV 

当然,您必须调整路径最后一个参数。

现在,当链接你的应用程序时,你的修改框架告诉链接器dyld必须在应用程序的应用程序包装中搜索OpenCV.framework在ClipSplitter.app/Contents/Frameworks目录中)。



现在您必须将OpenCV.framework复制到应用程序包装中。通过添加复制文件构建阶段,您可以将其作为构建过程的一部分:右键单击目标,选择添加 - >新建构造阶段 - >新建复制文件构建阶段。从弹出的Destination中选择Frameworks并关闭对话框。

您的目标将包含一个新的阶段,您可以通过拖动来添加OpenCV.framework Xcode窗口左侧Project Navigator中的图标。请注意,Xcode不允许您使用'+'按钮将文件夹添加到复制文件阶段,因此为了复制框架,您必须拖放它。


I am an XCode novice. I am trying to follow these instructions. Clearly I am missing something because while I can see that the framework I want has been copied into the app bundle, I can't reference it.

When I start the application from a machine other than mine (or if I remove OpenCV from /Library/Frameworks/ ) I get the following error:

Dyld Error Message: Library not loaded: /Users/david/Library/Frameworks/OpenCV.framework/Versions/A/OpenCV Referenced from: /Users/g/Demo/Slates/ClipSplitter/build/Release/ClipSplitter.app/Contents/MacOS/ClipSplitter Reason: image not found

There is no user "david" on my system if that makes any difference. Also this is a prebuilt OpenCV downloaded from the internet. (Here’s a screenshot of the project as requested in comments.)

解决方案

When the OpenCV.framework has been build it has been configured to use an install path of /Users/david/Library/Frameworks/.

Since you want to use the library as a private framework (installed in the application wrapper at ClipSplitter.app/Contents/Frameworks/OpenCV.framework) you have to change its install path. This can be done easily using the terminal as follows:

$ install_name_tool -id @executable_path/../Frameworks/OpenCV.framework/OpenCV <your_path>/OpenCV.framework/OpenCV

Of course you have to adjust the path of the last argument.

Now, when linking your application, your modified framework tells the linker that dyld has to search for the OpenCV.framework in the app wrapper of your application (in the ClipSplitter.app/Contents/Frameworks directory).

Now you have to copy the OpenCV.framework to your application wrapper. You can do this as part of your build process by adding a copy files build phase: Right-click on your target, select Add->New Build Phase->New Copy Files Build Phase. Select "Frameworks" from the "Destination" pop up and close the dialog.

Your target will now contain a new phase to which you can add the OpenCV.framework by dragging the icon from the Project Navigator on the left side of Xcode window. Note that Xcode won't allow you to add a folder to the Copy Files phase by using the '+' button so in order to copy the framework you'll have to drag&drop it.

这篇关于在XCode中绑定带有应用程序的框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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