Re: turn a group into a real folder?
Re: turn a group into a real folder?
- Subject: Re: turn a group into a real folder?
- From: James Bucanek <email@hidden>
- Date: Fri, 16 Jun 2006 07:14:45 -0700
Matt Neuburg wrote on Friday, June 16, 2006:
>I know that when I add a folder full of files to a project, I can elect to
>create groups (in the project window) for that folder's hierarchy.
>
>But how do I go the other way? That is, as my project as grown, I've divided
>the files into groups in Xcode. Now I'm thinking I'd like the folder
>hierarchy on disk to reflect these groupings (e.g. this would make it easier
>to navigate the project when viewing the svn repository over the Web). Is
>there some way to say to a group "folder" that it should become a real
>folder (like Pinocchio becoming a real boy)?
What is somewhat hidden in the Xcode user interface is that all groups reference a "real" folder. Source items and subgroups can (optionally) be based their references relative to their enclosing folders group by using "Relative to Enclosing Group" references -- but this is the default, so it's likely that all of your source items are "Relative to Enclosing Group."
The reason it doesn't appear that groups are "real" is that by default all groups you create refer to the same folder that's used by their supergroup, the top most being the project folder. So, by default, all source files get lumped together in the project folder.
Here are two ways of reorganizing your project.
- - - - -
To move the individual source item in a group into their own folder:
1) Create your folder. If you are using source control, I find it easiest to use the source control commands to create the folder, then the new folder is already in SCM (e.g. 'svn mkdir Common').
2) Move the files and folder and correspond to the source items and subgroups contained in that group into your new folder. Again, if you're using source control, I suggest using the source control commands to do this so that the SCM doesn't get lost (e.g. 'svn mv Utilities.c Common/'). Also make sure that everything is checked in before you start moving things around as many SCM systems don't like to rename/delete files that have local modifications.
This will "break" the item references in Xcode and all of your items will turn red (meaning that Xcode can't find them anymore).
3) Select the source group and use the Get Info command to display it's attributes. Click on the Choose button and select your new folder.
If all of the source items in your group were "Relative to Enclosing group," the change in the enclosing folder's reference should fix them all and they will turn black again.
Repeat with your remaining folders.
- - - - -
Now, if you have a *lot* of these to do, and you aren't under source control, and you haven't tweaked the attributes of your individual files (i.e. you've individually changed anything in the Get Info window for individual files like encoding, or type, or compiler flags), then there's an easier way:
1) Delete all of your groups in the Xcode project. Go to the Finder and create new folder, subfolders, etc and reorganize everything the way you want it.
2) Grab all of the top-level source files and folders in your newly reorganized project and drag them back into your Groups and Files pane. Xcode will attempt to import them into your project again.
- Turn "Copy items" off
- Set the Reference type to Default
- Select "Recursively create groups for any added folders
Choose your targets and let Xcode rebuild your project. After its done, every folder and subfolder will be a group with an "enclosing group" references that points to the "real" folders you just created. In otherwords, you'll have a source groups and items that mirror your physical folders and files.
James Bucanek
____________________________________________________________________
Author of Beginning Xcode ISBN: 047175479X
<http://www.beginningxcode.com/>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden