1

I have a header file named A.h, another header file named B.h.

In B.h,

#include "XYZ/A.h"

but Xcode complains "XYZ/A.h" file not found.

I tried to make a subfolder XYZ in the folder where B.h is, and put A.h into XYZ, but the same error.

How to solve this? ===> Set parent folder of XYZ folder in project build setting "header search path". Problem resolved!

I don't want to change the header file B.h - I want to keep the relative path "XYZ/A.h".

PLEASE NOTE: Both A.h and B.h are added into project (dragging...), and their physical location is not same with group folder in Xcode project. They may be in different folders in disk.

1

1 Answer 1

5

I am not particularly familiar with XCode but generally the compiler needs to know where to start looking when using relative include paths. For this reason, through compiler options or project options (since you are using an IDE), you must set the path to the directory that contains the directory XYZ. So if the path to XYZ is '/home/user/XYZ', then you need to add '/home/user/' to the search paths.

Now this is generally speaking. XCode may do it in a slightly other way but the point should be the same.

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

1 Comment

+1 This is correct; there is a 'header search path' setting in Xcode for this purpose.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.