How do I create a bundle of reusable code in Xcode? How do I create a bundle of reusable code in Xcode? xcode xcode

How do I create a bundle of reusable code in Xcode?


Create a static library project, then use the interproject dependency feature of Xcode to build them in the correct order and link the app with the static library. You'll need to have a common build directory set for all the projects for this to work correctly (at least you did around Xcode 3.0, didn't check if this is still a problem with 3.1).

You can set the build directory from the target or project's build settings (in the Get Info pane). To create an interpoject dependency:

  • Drag the library project into the application project's Files & Groups pane.
  • Set up target dependency in the application target's Get Info pane. Make it dependent on the library's target.
  • Drag the library product in the application target's Link With Libraries step. You can find the library product by expanding the library project within the app project's Files & Groups (click the arrow).

Sounds more complicated than it is. It isn't much.

(Small extras: yes, you need a common build folder as indicated in the Xcode Project Management Guide, and the Xcode Build System Guide can help you "get" Xcode's build system, which -- at the cost of starting a religion war -- I think is one of the most flexible and simple build systems out there.)