错误“未加载库”当启动应用程序 [英] Error "Library not loaded" when launching app

查看:129
本文介绍了错误“未加载库”当启动应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个使用



如果要在另一个框架中捆绑框架,可以使用 @loader_path 而不是 @executable_path


I have created a Mac app which uses the RMSharedPreferences framework. When opening the app, it immediately crashes and I get the following error:

Dyld Error Message:
  Library not loaded: @rpath/RMSharedPreferences.framework/Versions/A/RMSharedPreferences
  Referenced from: /Users/USER/Desktop/MyApp.app/Contents/MacOS/MyApp
  Reason: image not found

It seems that it can't find the framework. I have tried adding a copy files phase to the target which should copy the framework and when browsing the contents of the app in Finder, it seems that it is copied correctly.

Does anyone know what might cause this error?

EDIT: Setting the framework to optional does make the application launch without any errors but the application does not fully work. Any RMSharedPreferences related calls will be ignored.

解决方案

Since you are bundling the framework with your app, you should set the framework's install location. You can set that in your framework target build setting "installation location". Use something like:

@executable_path

You could also use a separate folder for your frameworks, then you would use:

@executable_path/../Frameworks/

In case you can't rebuild the framework (which is not yours, but I am saying in general), you can modify a prebuilt framework installation path like this:

install_name_tool -id @executable_path/../Frameworks/<framework_name> <your_framework>

Here you can find a reference for this.

If you are going to bundle a framework inside another framework, you can use @loader_path instead of @executable_path.

这篇关于错误“未加载库”当启动应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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