views:

51

answers:

3

I'm trying to wrap my head around xCode's file organization - or lack there of. I can do all I wan in project and it looks great with all the "fake" folders and structure. I go look at the file system and boom HUGE mess. I've tried importing files with the Create Folder Reference for any added folder option checked and that works, kinda. I get the structure I want both in xCode and on the filesystem.

Issues: When I add a file to a folder on the filesystem that is a Folder Reference in xCode, its not in xCode when I go look, not even after reloading the project. Files/Subfolders in a Folder Reference can't be moved around in xCode. When I move them on the filesystem I get red links (can't find the file?) in xCode.

How do I keep a organized project and filesystem? How can I set up a project to just recognize a folder and show its (current and up-to-date) files and subfolders in my project?

Another issue I seem to run into, if I use a Folder Reference and change a file, the file is not updated in my application unless I do a full clean & rebuild. If I don't use a Folder Reference, all my files are dumped into the Resource folder of the application bundle, not in the nice structure I have in my project.

Should I care at all? Should I just use the fake folders and let everything go everywhere and not care? My application bundle will be a mess, the filesystem will be a mess, but it will all work... I would hope?

Edit:

My biggest reason for wanting an organized filesystem is that the resource files (images, sounds, other datafiles, etc.) are not edited in xCode. I have to access them in 3rd party apps via the filesystem. If its a mess things are harder to find and maintain in the other 3rd party applications.

Also what happens if I want a structure like the following:

  • Images/Backgrounds/Name.png
  • Images/Icons/Name.png
  • Images/Titles/Name.png

Should I use long filenames rather than folders to organize?

  • Images_Backgrounds_Name.png
  • Images_Icons_Name.png
  • Images_Titles_Name.png
A: 

Should I care at all? Should I just use the fake folders and let everything go everywhere and not care? My application bundle will be a mess, the filesystem will be a mess, but it will all work... I would hope?

IMO no... :) basically. The whole point is that XCode has been designed to give you the best experience of programming. If Apple wanted you to physically organise all your files and folders within the actual filesystem then they would have made it that way.

I don't really understand why you would want to organise all the files and folders in this way anyway? It makes no difference to the running of the application and the "fake" folders (groups) in XCode adequately provide the necessary visual aid for yourself (and others) to navigate through your classes and other resources. Organising it correctly in your filesystem (as you have found) surely just makes things more difficult?

Thomas Clayson
See my above edit for my reasoning. Unfortunately, I'm seeing if I want to use XCode then I just have to say F it and deal with the FUBARed filesystem organization. If I want to dev for the mac, I need to use XCode so, I'll deal I guess... just goes against my 20 years of programming to leave a project folder a massive mess.
Justin808
lol... well times they are a changing (as bob dylan once said). My background is web development where all your images are in the images folder and you have a seperate psd and you save to the images folder when you want to use an image, so here's what I suggest you do: have `Development/MyAppProject` which has `/MyAppProject` and `/MyAppProjectResources` in it. In MyAppProjectResources you have your structured filesystem of PSDs and XMLs and whatever else and when it comes to using them in your acctual app you can either save into `/MyAppProject` folder or drag and drop the resulting files.
Thomas Clayson
+2  A: 

OK, so here is how it works:

Xcode doesn't know about any files until you tell it about them. That is, even if you add a file manually in the finder (usually a bad idea) to a folder that contains files in an Xcode project, it doesn't know about them until you "add existing file to project".

The best practice (imo) for adding an existing file (or group of files) to a project (say, some code you just downloaded) is to choose "add existing files" and then "copy items to destination group's folder (if needed)" in the next dialog, if you want your project to have a copy of the files in question, rather than merely a reference to them (there are advantages and disadvantages of both).

Don't worry too much about the naming of folders in Xcode, or where you put things, but try to keep to a standard that makes sense in your environment. For example, I always put the classes I write in "Classes", and have separate folders for any library code i've downloaded for use in the project. I always put images/icons/audio etc in to "Resources".

In short, if you like what's in the project folder to be approximately the same as what's in your project, always add existing files by choosing the "copy items to destination group's folder"

The flexibility in XCode is intentional. It's up to you to decide how you like to organise things.

hmm.. what you call flexibility in XCode I see as a major major bug. Why would I want to have things organized in the project 1 way and be, IMO, completely FUBARed on the filesystem? The **copy items to destination group's folder** does nothing to keep files organized within the projects folder on the filesystem, it just copies a file being added from outside the project to the big mess of the project's folder.
Justin808
A: 

It would be great if Xcode could keep itself and the file system in sync. Unfortunately it doesn't. One reason for wanting it to is so the hierarchy in your SCCS matches the one in Xcode.

I fall back to keeping things organized in Xcode, and leaving the file system separated into not much more than "Classes" and "Resources".

Graham Perks