问题
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:
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.
来源:https://stackoverflow.com/questions/11772980/include-header-file-in-xcode-c-project