Useful Command-Line Tools

Apple has created or modified several command-line tools for compilation, debugging, performance analysis, and so on. Table 4.2 lists some of the more useful tools. You can get further information by using the manpages system. The tools are all located in the /usr/bin directory.

Table 4-2. Command-Line Development Tools

NameDescription
cc

Compiles C, Objective-C, and C++ source code files.

gdb

Is a source-level symbolic debugger for C, extended by Apple to support Objective-C and C++.

gnumake

Builds the product(s) of a programming project based on dependency information.

as

Assembles; translates assembly code into object code.

defaults

Reads, writes, searches, and deletes user defaults. The defaults system records user preferences that persist when the application isn’t running. When users specify defaults in an application’s Preferences panel, NSUserDefaults methods are used to write the defaults.

nibtool

Reads the contents of an Interface Builder nib file. Prints classes, the hierarchy, objects, connections, and localizable strings.

libtool

Creates static or dynamic libraries from specified object bin files for one or multiple architectures.

otool

Displays specified parts of object files or libraries.

nm

Displays the symbol table, in whole or in part, of the specified object file or files.

fixPrecomps

Creates or refreshes a precompiled header file for each of the major frameworks.

strip

Removes or modifies the symbol table attached to assembled and linked output.

Although the Mac OS X development environment includes many of the tools discussed in this chapter, the tutorials in this book focus almost exclusively on the use of Project Builder and Interface Builder. Some tools, such as the compiler and the linker, are usually invoked indirectly through Project Builder. Most other tools are not strictly necessary for building Cocoa applications. However, the debugging and performance analysis tools ObjectAlloc, QuartzDebug, and Sampler are extremely useful for understanding the details of an application’s inner workings. Feel free to experiment with them at any point in the tutorial-building process.

Get Learning Cocoa now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.