Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCode, folders and #import statement

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.

like image 398
Dmitriy Avatar asked Aug 22 '11 11:08

Dmitriy


People also ask

Where is Xcode folder stored?

Most caches are stored in ~/Library/Caches, including the Xcode cache. You'll find Xcode's cache at ~/Library/Caches/com. apple.

What does a red folder mean in Xcode?

It means they are not found on disk where your project believes they should be. Control-click and Show In Finder to see the folder location to locate the file and drag it back in to the project, and delete the bad reference.

How do I see all files in Xcode?

Press and hold the ⌘ + shift and . keys at the same time. Then you can switch to view hidden/non-hidden files. Save this answer.

How do I open a Xcode folder?

Importing into Xcode Open Xcode and select Open Another Project or File, Open. Open the folder you unzipped from your Dropsource download and locate the file with “. xcodeproj” extension in the root directory. Select the file and click Open.


3 Answers

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.

like image 200
Hussain Mansoor Avatar answered Oct 13 '22 07:10

Hussain Mansoor


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.

like image 21
ennuikiller Avatar answered Oct 13 '22 05:10

ennuikiller


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.

like image 35
Nicholas Smith Avatar answered Oct 13 '22 05:10

Nicholas Smith