The first question that comes to mind when talking about application bundles is how do you create the bundle. The good news is you don’t have to do any work to create an application bundle if you use Xcode. Xcode’s Cocoa and Carbon application projects are set up so all you have to do is build the project to create the bundle.
Now that you know how to create an application bundle, a second question comes to mind. How do you get your files into the application bundle?
The Groups and Files list runs along the left side of Xcode’s project window. You should see a Resources folder in the Groups and Files list. Files in the Resources folder will get copied to the Resources folder in the application bundle when you build the project. To add files to the application bundle, you must add them to the Resources folder in your project and build the project.
If you want to make sure the files you added will get copied to the application bundle, check to see if they are in the Copy Bundle Resources build phase for your project’s target.
If your application uses lots of files, organizing them into folders makes sense. Suppose you have a game with 50 levels, 75 graphics files, and 75 sound files. Throwing all 200 files into the application bundle’s Resources folder would be messy. Having separate folders for the levels, graphics files, and sound files makes finding specific files in the bundle easier. How do you add folders to the application bundle?
Adding folders is no different than adding individual files. Add the folder to your project using the steps I detailed last section. There is one thing to keep in mind. When you add a file or a folder to your Xcode project, you will see the following sheet:
Xcode has two options for adding folders to a project: recursively create groups and creating folder references. Create a folder reference when you want to copy the folder to the application bundle.
Next (Reading Files from the Bundle)
Previous (Introduction)