adding an external library to a project in XCode 4.3

20,046

By default, Xcode searches for headers recursively in the project's own directory. If you're using a static library, you'll need to use the lib's header files which likely reside somewhere else. There are 2 settings in an Xcode project that allow you specify additional paths to search during compilation:

User Header Search Paths

#import "SomeHeader.h"

Header Search Paths

#import <SomeHeader.h>

Depending on which style you intend to use, pick the appropriate setting, and supply the path to the header files you wish to use:

enter image description here

The paths can be recursive, relative to the project (using $(SRCROOT)/), or absolute. You could also use the derrived data directory if you have Xcode set up correctly.

Share:
20,046
Joel Derfner
Author by

Joel Derfner

Classicist manqué, living Latin enthusiast, ne'er-do-well. In real life I'm a musical theater composer and author of decidedly non-academic books.

Updated on July 09, 2022

Comments

  • Joel Derfner
    Joel Derfner almost 2 years

    Newbie here, trying to add the CHDataStructures library to a calculator project I'm working on. I did as suggested in the accepted answer at Linking a static library to an iOS project in XCode 4 and have ended up with this:

    XCode with library added

    Unfortunately, I get a 'CHDataStructures.h' file not found error when I try to add the header to classes in my project (Calculator.m, for example).

    Any thoughts about how I can get the CHDataStructures library to be, like the Death Star, fully operational?

    EDIT

    Okay, here's trying both $(SRCROOT) and the absolute path. Any thoughts?

    with `$(SRCROOT)

    with absolute path