Reputation: 1972
I'm writing an app for the iOS in XCode 4 and stumbled upon an issue with #import statement.
All my source files are organized in folders, every folder is mapped to the group or subgroup in XCode. Consider the following:
ProjectFolder
-SubFolderA
--FileA.h
-SubFolderB
--FileB.m
Usually, if I want to import FileA into FileB, I write #import "FileA.h"
, and it works perfectly. But sometimes I have to write relative path, like #import "../SubFolderA/FileA.h"
. What should I do to be always able to write only name of the file?
This behavior seems undetermined to me.
PS: I don't want to keep all this mess in one root folder.
PS#2: Yes, I know how the 'folder' differs from 'group'. I've created folders on the early stage of the project, dragged them from Finder to XCode and mapped them to groups. And everything worked just fine - I was able to import headers using only filenames.
Upvotes: 10
Views: 10542
Reputation: 3134
Search "Scan All Source Files for Includes" in your project's and target's build settings and change the value from "NO" to "Yes". It will solve this issue.
Upvotes: 7
Reputation: 11754
XCode is very much like iTunes in some respects, it wants to manage your files and hide them from you. When you create a group in XCode it's appearance is that of a 'folder' but if you go into the actual project folder you'll still see files everywhere.
Upvotes: 1
Reputation: 46965
You can always set the "Header Search Paths" under build options to specify which directories to search in. Don't confuse folders and groups though. They are completely independent. In particular groups are simply a convenience that allow you to organize your files within Xcode.
Upvotes: 6