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.
@rpath is a more flexible keyword, and its use is recommended.
The better way to do this is to set the "Runpath Search Paths" build setting in Xcode.
This avoids the need for an additional build phase script to modify the framework.
For instance, in your situation, you could set "Runpath Search Paths" to
or
if you're trying to load the framework from within a framework.
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:
You could also use a separate folder for your frameworks, then you would use:
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:
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
.