Graphics Programs Reference
In-Depth Information
For the More Curious: Build Phases, Compiler Errors, and
Linker Errors
Building an application in
Xcode
takes several steps. We call these steps
build phases
, and
you saw them earlier in this chapter when you added the Core Location framework to the
Whereami
target (
Figure 4.2
). Here is what each build phase does:
Compile Sources
This build phase contains the source code files that are compiled when this target
is built. By default, any time you add a source code file to a project, it is added to
this build phase.
Link Binary With Libraries
After your source code has been compiled, it is linked with the frameworks (lib-
raries). This allows your code to use classes from these frameworks.
Copy Bundle Resources
After your code is compiled and linked, an executable is created and placed in-
side an application bundle, which is really just a folder. Then the resources listed
in this phase are added to the bundle alongside the executable. These resources
are the data files that your application uses at runtime, like XIB files and any im-
ages or sounds that are part of the application. By default, when you add a file to
a project that is not source code, it is added to this build phase.
We usually see errors during the
Compile Sources
phase, but sometimes we get errors dur-
ing the
Link Binary With Libraries
phase. Errors generated during these phases are easier
to diagnose and correct if you understand them in more detail.
Preprocessing
The
Compile Sources
build phase can be broken into two steps: preprocessing and compil-
ing. The goal of the preprocessing phase is to create an
intermediate file
for each imple-
mentation file (
.m
). The intermediate file is still Objective-C code like the implementation
file, but, as we will see, the intermediate file can get very large.