Search code examples
xcode4static-linking

In Xcode 4, how create a multi-shared project setup?


I'm developing now several iOS apps that shared some common thirdy-party libs, plus some shared code of my own.

This is my folder layout:

-three20/

Common setup of all my apps:

-Shared/*chibiORM* (ORM layer)
-Shared/**BaseApp** (This link to chibiORM & three20)
---------------/Libs/(Several small 3dparty libs)

This apps must link to BaseApp, and have three20, chibiORM & 3dparty- party libs access..

- App1 
- App2
- AppN...

I know how link a static lib to a single project, but fail to do this multi-link setup, where BaseApp link to three20, chibiORM, other utilities and App1..N link to all the previous.

I prefer not to link to each one one by one (my current setup), but instead all of them in one go.

I can compile fine BaseApp, and simply add the project /drag&drop) to App1. Then, I put the headers/frameworks/Library Paths to point to all of them (I wonder if this could be simplified to a single path, instead of put 5 here) but get this errors for each lib linked from BaseApp:

Undefined symbols for architecture i386:
  "__ALog", referenced from:
      -[App1AppDelegate closeDb] in App1AppDelegate.o
      -[App1AppDelegate application:didFinishLaunchingWithOptions:] in App1AppDelegate.o
      -[BoardViewController cardSelected:indexPath:] in BoardViewController.o
      -[BoardViewController gestureRecognizerShouldBegin:] in BoardViewController.o
      -[BoardViewController moveActionGestureRecognizerStateChanged:] in BoardViewController.o
      -[BoardViewController finishedSnap:finished:context:] in BoardViewController.o
      -[BoardViewController animationDidStop:finished:context:] in BoardViewController.o
      ...
  "_sqlite3_unicode_free", referenced from:
      -[App1AppDelegate closeDb] in App1AppDelegate.o
  "_sqlite3_unicode_load", referenced from:
      -[App1AppDelegate application:didFinishLaunchingWithOptions:] in App1AppDelegate.o
  "_OBJC_CLASS_$_Db", referenced from:
      objc-class-ref in App1AppDelegate.o

Is this possible?


Solution

  • I finally make it work combining the ideas from http://blog.carbonfive.com/2011/04/04/using-open-source-static-libraries-in-xcode-4/ & http://www.clintharris.net/2009/iphone-app-shared-libraries/.

    (The errors was because I forget to link the lib to the project, and unrelated to the question btw).

    The main trick is to set the install directory to $(BUILT_PRODUCTS_DIR) in the static lib targets.