嵌入式框架与捆绑包外部的版本冲突
我的一个 Mac 应用程序包含一个框架,我将其嵌入到应用程序包中。现在我发现一些证据表明,在某些客户计算机上,应用程序链接到位于 /System/Library/Frameworks 文件夹中的同一框架。
当涉及到将嵌入式框架链接到 XCode 中的应用程序时,我显然遗漏了一些东西,所以这就是我的做法..也许您可以指出我缺少的步骤:
1)我将框架项目拖到我的项目并设置两个项目之间的依赖关系 2)我将框架项目的构建产品拖到目标的“Link Binary with Libraries”构建阶段 3)我将框架项目的构建产品拖到目标的“复制框架文件”构建阶段,设置为“目标:框架”
这一切都很好,但我需要在某个地方指定我想要与嵌入式版本链接框架而不是系统上可能找到的任何框架版本。是否需要在某处设置搜索路径?或“静态”链接?
任何帮助将不胜感激。
最好的问候,
弗兰克
One of my Mac applications contains a framework which I embed into the application bundle. Now I have found some evidence that on some customer machines the application links against the same framework located in the /System/Library/Frameworks folder.
I'm obviously missing something when it comes to linking the embedded framework to the application in XCode, so here's how I've done it.. and perhaps you can point me to the missing step:
1) I drag the framework project into my project and set up the dependency between both projects
2) I drag the build product of the framework project to the "Link Binary with Libraries" build phase of my target
3) I drag the build product of the framework project to the "Copy Framework Files" build phase of my target set to "Destination: Frameworks"
This all works great but somewhere I need to specify that I want to link with the embedded version of the framework rather than any framework version that might be found on the system. Is there a search path to be set somewhere? or "static" link?
Any help would be appreciated.
Best regards,
Frank
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您可能缺少一个关键步骤。您还需要设置嵌入式框架的“安装名称”。
当您链接框架或动态库时,您的应用程序将在框架的安装名称指定的路径中查找框架。这应该指定嵌入式框架的相对路径。如果它是绝对名称,即使您已经嵌入了该库,它也会选择系统安装的版本。
要检查安装名称,请执行以下操作并查看第一个位置。
这两篇博客文章解释了这个问题以及如何正确设置所有内容:
此外,如果您从命令行编译 dylib(例如开源库),只需将以下内容添加到 CFLAGS 中即可设置安装名称。
如果要修改现有二进制文件的安装名称,请使用“install_name_tool”。
还要确保您的复制文件构建阶段将正确的文件复制到应用程序包中的正确位置。
Sounds like you might be missing a key step. You also need to set the "install name" of your embedded framework.
When you link a framework or dynamic library, your app will look for the framework at the path specified by framework's install name. This should specify a relative path for embedded frameworks. If it is an absolute name it will pick up the system installed version, even if you've embedded the library.
To examine the install name do the following and look at the first location.
These two blog posts explain the issue and also how to set everything up properly:
Additionally, if you're compiling a dylib from the command line (say an open source library) just add the following to your CFLAGS to set your install name.
If you want to modify an existing binary's install name use 'install_name_tool'.
Also be sure your copy files build phase is copying the right files into the right places in your app bundle.