How to include a static library and have its #import paths still be valid?
Say I have a static library that was created with the following file structure:
- Folder1
- File1.h
- Folder2
- File2.h
Now inside of File1.h
, it refers to File2.h
without a path (e.g. #import File2.h
). The library builds successfully. (It doesn't require the full path (i.e. #import Folder2/File2.h
) because both files are part of the same project.)
Now when I include this library in another project, that #import File2.h
statement no longer compiles, and I have to change it to #import Folder2/File2.h
(or something similar). This means that I have to modify the original library, which is not good.
The specific error message I ge开发者_开发技巧t is:
File2.h: No such file or directory
There doesn't seem to be a way to let it know that both files should be a part of this new project, since the only two files I see after I included the library are MyLib.xcodeproj
and lixMyLib.a
.
The way I included the static library in my new project is by doing the following:
- Drag
MyLib.xcodeproj
into my new project. - Add the
libMyLib.a
file to my new project's target. - Add to the Header Search Paths a relative path to the home directory of my library (the folder that contains
Folder1
andFolder2
).
Is there any way I can have it automatically know where to find these files just as it was able to do in the library itself? I realize that I can probably add the paths Folder1
and Folder2
to the Header Search Paths of my new project, but I'm looking for a better way, since these two folders are just an example, and it could just as easily be 50 folders I would need to include. I'm looking for a solution which doesn't require me to type the paths to all 50 of those folders, if possible.
Try checking the "Recursive" checkbox next to the path to the parent folder of all those headers.
精彩评论