建立与私人dylib /框架Cocoa应用程序捆绑 [英] Build Cocoa application Bundle with private dylib/framework

查看:174
本文介绍了建立与私人dylib /框架Cocoa应用程序捆绑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用x code 4建立了私人dylib /框架Cocoa应用程序。

在我的Mac开发,我把dylib位于/ usr / local / lib目录目录下,并将其拖动到项目中。

该应用程序被编译并运行完善我的电脑上。

要分发此应用到另一台Mac,我创建了一个文件拷贝建设阶段,并说:复制dylib为框架目录。

在成功构建应用程序,而我确实看到了dylib被复制到应用程序包中的框架目录。

问题是,当我运行这个程序,在另一个常规的苹果,它没有这个dylib安装。我得到一个错误说:

库未加载:/usr/local/lib/mylib.dylib

  dyld的


解决方案

这个问题来自于你复制了一个框架,应用程序捆绑的事实,所以它是在一个位置,如:

 < you_app_path> /内容/框架

但你尝试从加载在/ usr / local / lib目录其中,它不可用在部署的机器上。从<一个href=\"http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPFrameworks/Tasks/CreatingFrameworks.html\">Apple框架编程指南:


  

要在应用程序中嵌入了一个框架,有您必须采取以下几个步骤:


  
  

您必须配置应用目标的构建阶段把框架的正确位置。


  
  

您必须配置框架目标的安装目录,它告诉框架在那里将生活。


  
  

,以便它引用该框架在其安装目录中,您必须配置应用程序的目标。


现在,你说,构建阶段是确定的;我想还你发送的应用目标构建设置正确。剩下的就是配置框架目标的安装目录。

如果你没有自己构建的框架,你应该能够通过改变框架安装路径来解决这个问题,使其相对于装载机(您的应用程序)所定义的,喜欢的东西: @ loader_path /../框架/ (或 @executable_path /../框架)。您可以通过<手段做到这一点href=\"http://developer.apple.com/Mac/library/documentation/Darwin/Reference/ManPages/man1/install_name_tool.1.html\">install_name_tool.

如果你在你自己的私人框架编译,可以以x code构建设置定义它的安装位置。

I use xcode 4 to build a cocoa application with a private dylib/framework.

In my development Mac, I put the dylib in the /usr/local/lib directory, and drag it into the project.

The app is compiled and runs perfect on my computer.

To distribute this app to the other Mac, I create a copy Files building phase, and say "copy that dylib to Frameworks directory".

The application is built successfully, and I indeed see the dylib is copied to the Frameworks directory in the app bundle.

The problem is when I run this app in another regular Mac, which does not have this dylib installed. I get an error saying:

dyld: Library not loaded: /usr/local/lib/mylib.dylib

解决方案

The issue comes from the fact that you copy the framework into the app bundle, so it is available at a location like:

 <you_app_path>/Contents/Frameworks

but you try to load it from /usr/local/lib where it is not available on you deployment machine. From Apple Framework Programming Guide:

To embed a framework in an application, there are several steps you must take:

You must configure the build phases of your application target to put the framework in the correct location.

You must configure the framework target’s installation directory, which tells the framework where it will live.

You must configure the application target so that it references the framework in its installation directory.

Now, you say that the build phase is ok; I assume also that you sent the application target build setting correctly. What is left is configuring the framework target’s installation directory.

If you did not build the framework yourself, you should be able to fix this by changing the framework install path so that it is defined relative to the loader (your app), to something like: @loader_path/../Frameworks/ (or @executable_path/../Frameworks). You can do that by means of install_name_tool.

If you are compiling on your own the private framework, you can define its install location in Xcode build settings.

这篇关于建立与私人dylib /框架Cocoa应用程序捆绑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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