Question

I've a number of frameworks that I'm linking to my main project but for some reason, whenever I run the whole thing outside Xcode the executable cannot find the frameworks at all.

The frameworks have the dynamic installation path set to @loader_path/../Frameworks. I've tried simply put @rpath but it didn't work either. Runpath Search Paths is empty on the main executable.

Is there an easy way to debug this? I think I've been through every website and blog post that talks about framework linking and nothing's been of help.

Was it helpful?

Solution

If, for example, you have a Build Phase where you copy the Frameworks into your app bundle…

Build Phase example

In your app Build Settings.. Runpath Search paths @executable_path/../Frameworks

In your framework Build Settings.. Dynamic Library Install Name @rpath/$(EXECUTABLE_PATH)

(where the macro $(EXECUTABLE_PATH) should be expanded to something like AFramework.framework/Versions/A/AFramework)

If you get it wrong your app should crash on startup. The crash report should say something like

Dyld Error Message:
  Library not loaded: @rpath/TestyFramework.framework/Versions/A/TestyFramework
  Referenced from: /path/to/TestyApp.app/Contents/MacOS/TestyApp
  Reason: image not found

which should help you work out what the values should be and where the framework should be

ie in my case the full runpath search path is..

/path/to/TestyApp.app/Contents/MacOS/TestyApp/../Frameworks

therefor the library should be found at..

/path/to/TestyApp.app/Contents/MacOS/TestyApp/../Frameworks/TestyFramework.framework
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top