Information Technology Reference
In-Depth Information
This applies equally to C/C++ source code, Objective-C class definitions, and resources such as graphics files. If
you use a library of custom icons or button graphics, you can keep the image files in a single folder and import
them into multiple projects as needed.
There are advantages and disadvantages to keeping files in multiple locations. The advantage is that you can
keep single copies and reuse them in multiple projects. The disadvantage is that it becomes harder to keep
safety copies of the files in a project. It also becomes harder to use the source control management (SCM) fea-
tures introduced in Chapter 14.
CAUTION
Typically after you build a project, Xcode copies graphics files into the application bundle. OS X allows your ap-
plications to create and access a common resource folder outside of the bundle. iOS doesn't. Be careful about
adding files to an iOS project. To minimize the size of the finished app, add only files that are used. Don't add
complete folders or resource collections.
Adding new files to a project
To save time, Xcode includes a selection of file templates that add prewritten content, including classes with
headers and implementation files that include minimal but useful boilerplate set-up and tear-down code.
The templates are similar to the application templates introduced in Chapter 3. Instead of creating a complete
application, they add a useful building block to an existing application. The templates for iOS and OS X are
slightly different, but they overlap significantly—much more than for the equivalent application templates.
You can add new files to a project in two ways: using Xcode's New File menu option or by dragging and drop-
ping the file from a template in Xcode's Utility area.
Using the New File menu option
You can select the New File menu option from the main Xcode menu via File⇒New⇒New File. You can also
right-click in or on a group and select New File from the contextual menu that appears when you right-click on
a group, as shown in Figure 5.1.
FIGURE 5.1
Adding a file using the New File option
Search WWH ::




Custom Search