objective-c – 使用私有dylib / framework构建Cocoa应用程序包

我使用xcode 4来构建一个带有私有dylib / framework的cocoa应用程序.

在我的开发Mac中,我将dylib放在/usr/local / lib目录中,并将其拖到项目中.

该应用程序已编译并在我的计算机上运行完美.

要将此应用程序分发到其他Mac,我创建一个文件构建阶段的副本,并说“将该dylib复制到Frameworks目录”.

应用程序构建成功,我确实看到dylib被复制到应用程序包中的Frameworks目录.

问题是当我在另一台没有安装此dylib的常规Mac上运行此应用程序时.我收到一个错误说:

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

解决方法

问题来自于您将框架复制到应用程序包中,因此可以在以下位置使用:

<you_app_path>/Contents/Frameworks

但是您尝试从/usr/local / lib加载它,在部署机器上它不可用.从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.

现在,你说构建阶段是好的;我还假设您正确发送了应用程序目标构建设置.剩下的是配置框架目标的安装目录.

如果您没有自己构建框架,您应该能够通过更改框架安装路径来修复此问题,以便相对于加载器(您的应用程序)定义它,如下所示:@loader_path /../ Frameworks /(或@executable_path /../框架).你可以通过install_name_tool做到这一点.

如果您自己编译私有框架,则可以在Xcode构建设置中定义其安装位置.

相关文章

我正在用TitaniumDeveloper编写一个应用程序,它允许我使用Ja...
我的问题是当我尝试从UIWebView中调用我的AngularJS应用程序...
我想获取在我的Mac上运行的所有前台应用程序的应用程序图标....
我是一名PHP开发人员,我使用MVC模式和面向对象的代码.我真的...
OSX中的SetTimer在Windows中是否有任何等效功能?我正在使用...
我不确定引擎盖下到底发生了什么,但这是我的设置,示例代码和...