xcodemacosiosdirectory

Moving Files into a Real Folder in Xcode


When I started my project I was happy to use Groups in Xcode rather than literal folders: Since I'm using the browser in Xcode to access everything, stuff was nicely organized and I was happy.

However, now that the project is about to be shared for version control, the project folder itself is a horror show for those trying to scan it via a terminal, about 300 files, over half of which are graphics.

I'm trying to now reorganize things, creating real folders and importing them into Xcode. Unfortunately Xcode doesn't let me work with them the way it does with groups. For example, if I right-click on an actual added folder (blue, not yellow) and choose to add existing files, it doesn't actually put them in that folder, it puts them in its root.

Similarly, I can't move a file from a faux-folder (a group) into a real folder: Xcode doesn't consider the real folders to be valid places to move stuff to.

What am I missing? How can I convince Xcode to let me use the folders the way I use groups? There's an answer here to a somewhat similar question, but it doesn't actually solve my problem since I'm working with existing files.


Solution

  • FURTHER EDITED JUNE 2017: Xcode 9 does this automatically, no special effort required. This answer and Brandon's only apply to Xcode 8 and earlier.

    EDITED DECEMBER 2016: Brandon's answer below is a better solution now. Back when this answer was created in 2010 this was the only option I could find. I now suggest Brandon's answer, below.


    It turns out that moving files into real folders is certainly possible, though not as simple as it should be.

    I got the basic information from a question here, Xcode organising files and folders (core data model objects - iPhone), but learned important things along the way.

    The Process

    Moving the files is a two-step process with multiple sub-steps:

    1. Tell Xcode where you want the files to be:
    1. Move the actual files

    Tips

    I learned a couple of important things while adjusting the ~300 files in this project: