Follow these steps to successfully create a bundle:
Create a root folder on your disk that will later become your bundle. For instance, let’s give this folder the name Resources.
Under the Resources folder, create three more folders named Images, Videos, and Sounds.
Under the three aforementioned folders, place related resources. For instance, place one or more images in the Images folder and one or more video files under the Videos folder and so on.
Once you are done, rename your Resources folder to Resources.bundle. Once you add this extension to your folder name, OS X will ask for your confirmation and a dialog similar to that shown in Figure 1-33 will appear on the screen. Press Add on the dialog to add the .bundle extension to the Resources folder.
If a bundle is added to the Navigator on the lefthand side of Xcode, any files added to or removed from the bundle outside Xcode will, respectively, appear in or disappear immediately from Xcode’s navigator. In contrast, if you had added a normal folder to Xcode’s navigator and then went and deleted a file from that folder on disk, without using Xcode’s help, you would see that file marked with red color in Xcode rather than getting deleted immediately. Bundles can be very useful, especially if you want to add files to your folders manually using Finder, instead of using Xcode.
Main bundles are flat bundles, in that all files inside the main bundle will be stored in one directory (its root directory). Bundles created by programmers can have subdirectories. Any bundle, including the main bundle, can contain other bundles.
Every iOS application comes with at least one bundle, called the
main bundle. The main bundle contains your app’s binary code and any
other resource you are using inside your application, such as retina
images, sounds, HTML files, and whatnot. The main bundle, in other
words, contains the resources that get compiled into your final binary
that you will submit to the App Store or distribute in your organization. These
resources can then be dynamically loaded using the
mainBundle class method.
Although you can add two or more bundles with the same name to one iOS project, it is best not to complicate things like that. The reason this situation could get complicated is that when we start loading resources from our bundles, we will first need to find our bundles by their path. If you have two bundles with the same name, it will become quite difficult to detect which is which. So as a good practice, make sure that your bundles have different names when you add them to your Xcode projects.