Information Technology Reference
In-Depth Information
The compiler converts the files generated by the preprocessor into machine code. The LLVM and GCC com-
pilers do this in different ways, but the end result is identical—a file with the .o (object) extension. Projects
that use source code in other languages can call an external compiler to produce compatible binaries.
Each source file in the project creates a separate object file. The linker combines them all into a single execut-
able binary, resolves symbol references to a specific location in the binary, and checks that all references are
present and correct. For example, if your code calls a framework, the linker checks that the framework is in-
cluded. If it can't find the framework or the specific symbol in it, it can't complete its task and the build fails.
The file copier processes supporting files. Different file types are processed in different ways, according to set
rules. For example, nib files are compacted, image files may be compressed, plists are processed using their own
separate processor, and so on. All processed files are copied to the target's product folder. Some may be handed
to the linker, so the point at which files are processed may vary.
The Xcode build system implements this scheme inside a customizable build manager. Each stage runs multiple
shell scripts. You can add your own scripts to the default build sequence. Potentially, you can even replace the
default scripts with your own custom-written alternatives, although this isn't a trivial job.
In practice, Xcode manages the build process through a combination of two elements:
Build phases select and process files of a given type. You also can add phases that run arbitrary scripts.
Build phases define when files are processed and when other scripted build events happen.
Build rules define the scripts that control what happens to a file with a specific extension. They define
how files are processed.
To customize a build fully you must know how to do the following:
Access the standard build settings and environment variables in your code, so you can add conditional
compilation features.
Create your own custom build settings for use in conditional compilation.
Create and manage build phases.
Create and manage build rules.
Introducing conditional compilation
Conditional compilation is an automated process that literally includes and excludes lines of code from your
source files. You create conditional code by surrounding it with preprocessor directives, which look similar to
conventional C code but are prefixed with the # character.
Table 13.3 lists the standard conditional and unconditional directives.
Search WWH ::




Custom Search