objective-cios5xcode4.2

adding an external library to a project in Xcode 4.3


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


Solution

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