Joel Hinz
Joel Hinz

Reputation: 25404

How can I make Xcode load the right string.h file?

I've inherited a bunch of folders with C files in them, and I'm supposed to make a library of them in Xcode for an iOS project. I have no prior C experience, although I've coded in Obj-C.

But the library does not compile in Xcode, and the issue appears to be that the previous coder has named a file gu/string.h. When, then, one of the files tries to include string.h from the standard library, Xcode chooses the first one instead.

The same code compiles fine on OSX (through the terminal), on Ubuntu, even on Windows, and .i files on those systems show that the inclusions are handled correctly.

Is there any way I can force Xcode to look for the files in the order I want it to? If not, I'll rename the file and fix the include directives - naming a file the same as a standard library file seems very trololo anyway - but I'd prefer to keep the code I got intact if possible.

Upvotes: 4

Views: 2167

Answers (1)

Rob Napier
Rob Napier

Reputation: 299355

The correct solution isn't to fix the name, but the include path. The best path is relative to SRCROOT (to top of your tree):

#import "somepackage/gu/string.h"

For some trees that's awkward, so you can set the Header Search Paths to include the directory that has gu in it. Then use:

#import "gu/string.h"

If that's not possible, you can add the whole path to User Header Search Paths and just make sure to use quotes rather than brackets.

Upvotes: 1

Related Questions