Using static libraries in Xcode 4

Posted by Daniel Vela on January 29, 2012
  1. First create the library project.
  2. For each header file make sure it is set as public in the “Target Membership” section of the inspector pane. inspector pane
  3. Set the following settings in build settings.
    • Installation directory => $(BUILT_PRODUCTS_DIR)
    • Skip Install => Yes
    • Public Headers Folder Path => $(TARGET_NAME) inspector pane
  4. Now create a new workspace for your project.
  5. Add the static library to your project.
  6. Add build target dependencies. Select apps build target and add the static library to the “Link binary with libraries” build phase. inspector pane
  7. Add the static libraries headers. Open “Build Settings” tab and locate “User Header Search Paths”. Set to $(BUILT_PRODUCTS_DIR) inspector pane
  8. Configure the projects scheme. Edit your project scheme and add the static library build target before our apps build target.
  9. Last include in the project precompiled header the library main headers (This step is optional)