Adding a folder to Xcode project

Romejanic picture Romejanic · Dec 2, 2013 · Viewed 18.5k times · Source

I have a folder full of files on my iPhone app which I want to use, but Xcode will not let me add folders to the bundle, only its files. I can't do this because I want it to be a bit more convenient, so I can reference the folder in my code. So, how do I do this? The compile settings in the build targets won't let me add the folder, only its files.

Answer

zaph picture zaph · Dec 2, 2013

Drag the source folder to the project "Groups & Files" area, say under the Resources group. In the dialog select "Create Folder References for any added folders". This will create a blue folder and the folder will and it's inter hierarchy will appear in the apps resources. This will automatically create an entry in "Copy Bundle Resources" build phase This is commonly done for image & help files. Any changes made to the folder will also change the files included by Xcode.

Note the important thing here: the folder must be a Folder Reference (blue folder). If it's a group (yellow folder), delete it and all its contents from your project tree, then re-add as a Folder Reference. Then make sure that's in the Copy Bundle Resources build phase. – cdespinosa