Configuring the Xcode project to add a new file to the custom directory


How can i setup my Xcode project so that it creates new class files (.h/.m) in Classes directory and new interface files (.xib/.nib) in Interfaces directory?

By default Xcode adds new files in the root project directory, and i have to manually put these into Classes and Interfaces directories.


I'm referring to the Xcode File > New File... option. I want the new files created from the Xcode project to move automatically to corresponding directories e.g. .h/.m files get automatically created in Classes directory, and .xib get automatically created in Interfaces directory etc. And i mean physical directories, not Xcode "Groups".

I assume you've made a group (folder) called Classes, or something along these lines, inside your Xcode project. Select it and do Command+I (or right-click it and select Get Info). Change the "Path" option to the place where you want files to be created.

Please note that it will only affect files you create on it. Creating them elsewhere then moving them to this group will not move them into the directory.

EDIT The above answer applies to Xcode 3. In Xcode 5, you would need to select the logical group in the Project Navigator (first navigator tab, bring it up with ⌘1) and then inspect it with the File Inspector (first utility tab, bring it up with ⌥⌘1). The default physical folder for all the new files can be changed by clicking the folder icon below the Location dropdown menu.