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

3
  • Point number 5 in the answer you linked to is critical for this. Did you follow it too? Commented Aug 3, 2012 at 22:41
  • Ah, no--I was hoping it wasn't crucial, because I have no idea how to do it. How do you add a Header Search Path? Commented Aug 3, 2012 at 22:43
  • It's easiest to use a picture, see the answer. Commented Aug 3, 2012 at 22:59

1 Answer 1

14

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.

Sign up to request clarification or add additional context in comments.

8 Comments

Thank you so much! That did it. And now I can aspire to knowing enough about coding to understand what I just fixed....
Drat. I thought I had it, but I don't quite understand what path to use. I tried $(SRCROOT)/Users/joel/Developer/CalculatorFourthTry [CalculatorFourthTry is the name of the file and that's the path to it] and "$(SRCROOT)/Users/joel/Developer/CalculatorFourthTry", which turned into "$(SRCROOT)/Users/joel/Developer/CalculatorFourthTry" /**, but I still get the errors. I'm formatting something wrong, I assume?
@JoelDerfner $(SRCROOT) is just an environment variable for "the absolute path to the .xcodeproj file". If you use it, you would then specify the path to headers relative to the .xcodeproj file, which isn't what you're doing there. You appear to be using an absolute path, but prepending the environment variable to it.
@JoelDerfner, as a sanity check, you can start by right-clicking on the header file in question, saying "Get Info", and copy/pasting the absolute path into the setting field.
Okay, THAT did it--I added $(SRCROOT)/ and the error went away like magic....
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.