views:

4946

answers:

1

I am developing an iphone application and have to parse xml files in order to put them into a database. I will also be using those same xml parsers in my app so users can import their own data. I was wondering how I can extract those xml parsers into a bundle or a library so I can use them both in my iPhone app and in a command line app where I just populate a sqlite3 database. Thanks in advance!

+8  A: 

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.)

millenomi
thanks for your detailed response. I will try it out when I get home tonight
You don't need to use a common build directory as of Xcode 3.1.1 (not 3.1).
Chris Hanson