How to setup Xcode to share code across iPhone projects

The long story is here: http://www.clintharris.net/2009/iphone-app-shared-libraries/

The short story is here.

Global Settings, i.e. do this once:

  1. Set up a shared build output directory that will be shared by all Xcode projects.
  2. Add a “Source Tree” variable that Xcode can use to dynamically find the static library project. (for each project to be shared)

Per Project Settings, i.e. for each project that uses the shared code

  1. Add the shared project to this project, DON’T select “Copy items into…”
  2. On linked project properties/General tab, select “Relative to COCOS2D_SRC”
  3. On the Target properties/General tab, add “Direct Dependencies” for the shared libs, e.g. cocos2d
  4. On the Target properties/Build tab, ensure there is no hard coded path in the “Library Search Paths” also add a “User Header Search Path” of $(COCOS2D_SRC)
  5. Drag the required static libraries from the shared project into the “Link Binary with Libraries” folder for your target.

And thats it :)

Leave a Reply

Your email address will not be published. Required fields are marked *