Recently I ran into an error submitting eatkeep to the Mac App Store. As it will eventually be a universal app (ios, mac) I created a project that generates a framework (mac) and a static library (ios).

The problem came upon review and receiving the following error from a stacktrace from the reviewer:

Dyld Error Message: Library not loaded: /Library/Frameworks/[framework-name].framework/Versions/A/[framework-name] Referenced from: /[path]/[app-name].app/Contents/MacOS/[app-name] Reason: image not found

Solution

The problem was due to the Installation Directory not being set correctly. You can find this setting under the Frameworks Build Settings.

What I had was:

$(LOCAL_LIBRARY_DIR)/Frameworks

and what I needed was:

@executable_path/../Frameworks

I found the solution on Stack Overflow and further information from Apple. The Apple documentation is useful so it’s worth a read over

The following has been extracted from the links mentioned above and should be enough to help fix this issue.

Building The Framework

  1. Add a target to create a Cocoa Framework
  2. Within that targets ‘Build Settings’ configure the ‘Installation Directory’ to [email protected]_path/../Frameworks’
  3. Build library, and access the .framework from the archive or products directory

Including The Framework

  1. Drag the created .framework file into the Xcode Project, be sure to tick ‘Copy Files to Directory’
  2. In the containing applications target, add a new ‘Copy File Build Phase’
  3. Set the ‘Destination’ to ‘Frameworks’
  4. Drag in the created .framework