For example I drag in a folder "SharedClasses
" with shared source code files as a folder reference into Xcode. The folder reference appears in the Project Navigator and lists all .h and .m files correctly.
But Xcode refuses to import them. I tried all kinds of import:
#import "Utility.h"
#import "SharedClasses/Utility.h"
#import <SharedClasses/Utility.h>
None of them work. But a folder reference exists and it contains "Utilities.h
"
Xcode knows where the folder comes from so what must I do that it looks inside it?
Holding the Command key, click the import/include statement to view the header. Also, you can Command-click on a symbol to jump to the header file that defines it.
Look at Preferences->Locations->"Custom Paths" in Xcode's preference. A path added here will be a variable which you can add to "Header Search Paths" in project build settings as "$cppheaders", if you saved the custom path with that name. Set HEADER_SEARCH_PATHS parameter in build settings on project info.
For C++ programs, it will also look in /usr/include/g++-v3, first.
Because the files are in a different folder than the project Xcode will not include it in the header search path. To fix this add an entry for User Header Search Paths (select your project, select Build Settings, filter to "user header search paths", add the value) in the project that points to the original folder reference. For example in a project I'm working on I have code that is shared between several projects in a workspace which is stored at the same folder level as the projects in a folder named shared. My User Header Search Paths has the following:
$(PROJECT_DIR)/../Shared/MySharedCode/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With