Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why in Xcode, Groups can be created, but not real folders?

Tags:

xcode

ios

iphone

When doing iOS programming, it is interesting that in Xcode (4.3.2), we can create groups, such as a group call Images, and add files to it (either as a link or choose "Copy items into group's folder"). So it looks like a real folder in the navigator, and it even mentions "copy into ... group's folder", but in fact there is no folder. All added files are in the same location as the .m and .h files.

Why would we want Groups, but not real folder? Is there advantage of Groups over the use of a folder?

like image 944
nonopolarity Avatar asked Apr 28 '12 22:04

nonopolarity


People also ask

How do I create a folder in Xcode?

You can create a new group, with its own folder, directly in Xcode, but it's not at all obvious. Instead of choosing 'New Group', choose 'Add Files to “<Project>”'. Then, in the file picker dialog, click the New Folder button or press Command-Shift-N and type the name of the new folder/group.

What is a group in Xcode?

A folder in Xcode represents a folder in the file system. A group in Xcode is a "fake" folder which does NOT represent a folder in the file system. It is common to use a combination of groups and folders for a given Xcode project. Follow this answer to receive notifications.

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.

What is create folder references Xcode?

Xcode relies on filesystem organization by keeping a reference to a "physical" file or folder. That is why you may have all the classes, images, plists, and other parts of your projects stored in the same folder, while the references to these parts are being kept organized into respective groups within Xcode project.


1 Answers

This is a pet peeve of mine.

I recommend, making the folder in your file system, where you have your project files, then drag that folder into Xcode where you want the group. It will act like any other group, but now be linked to the folder on the file system. Adding files to that group in Xcode now adds them to the folder in the file system.

Much cleaner way of working and helps when locating files in big projects. Keeps git cleaner too.

Update for Xcode 9:

Once you have the groups in Xcode matching the directory structure on disk, moving a file from one group to another in Xcode will now move the file correctly on disk to match.

like image 148
Dave Wood Avatar answered Sep 21 '22 08:09

Dave Wood