Blog

Headnix — Clip It!

Friday, May 08, 2009 Embedding private framework in your iPhone app

Been trying to embed the JSON framework in a client’s project.

Apple has a Framework Programming Guide where you can find a chapter which covers this topic – Embedding a Private Framework in Your Application Bundle.

So I follow the procedures there which I would summarize into the following:

  1. Add the framework to your project
  2. Add a new Copy Files Build Phase to the application target. (This phase will be used to install the framework in the application bundle.)
  3. In the General tab of the inspector window, set the destination for the build phase to “Frameworks”.

Well… it doesn’t work at all… Guess the instruction is specific to Mac OS X instead of iPhone OS.

I got the following runtime error:

dyld: Library not loaded: @loader_path/../Frameworks/JSON.framework/Versions/A/JSON Referenced from: /Users/bill/Library/Application Support/iPhone Simulator/User/Applications/9A0DCEEB-BD46-45E0-AA7E-8C0409256267/CocoaZendesk.app/CocoaZendesk Reason: image not found

Google around for solution…

The discussion in objectiveflickr forum showed some hint. We should load the framework from @loader_path/Frameworks instead of @loader_path/../Frameworks.

To do so… add a “New Run Script Build Phase” and put the following in the inspector window:

/usr/bin/install_name_tool -change \ “@loader_path/../Frameworks/JSON.framework/Versions/A/JSON” \ “@loader_path/Frameworks/JSON.framework/Versions/A/JSON” \ “$BUILT_PRODUCTS_DIR/$EXECUTABLE_PATH”

It works!!

If you are looking for Finger iPhone app, please go to Finger's site.

Copyright © 2007 Headnix. All rights reserved. Design by BeansBox.