Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
When you write programs for Mac OS X or iOS, you should write and compile your programs using Xcode, Apple’s Integrated Development Environment (IDE). You’ll learn how to set up a simple Xcode Project in Chapter 4, “Your First Objective-C Program.” However, for the simple C programs required in the exercises in this chapter and the next chapter, you may find it easier to write the programs in your favorite text editor and then compile and run them from a command line, using gcc, the GNU compiler. To do this, you will need:
1. | A terminal window. You can use the Terminal app (/Applications/Terminal) that comes with Mac OS X. If you are coming from another Unix environment, and you are used to xterms, you may prefer to download and use iTerm, an OS X native terminal application that behaves similarly to an xterm. (http://iterm.sourceforge.net/). |
2. | A text editor. Mac OS X comes with both vi and emacs, or you can use a different editor if you have it. |
3. | Command line tools. These may not be installed on your system. To check, type which gcc at the command prompt. If the response is /usr/bin/gcc, you are all set. However, if there is no response or the response is gcc: Command not found., you will have to install the command line tools from your install disk or from a downloaded Xcode disk image. (You can find a link to the current version of the developer tools on the Mac Dev Center web page, http://developer.apple.com/mac/). Start the install procedure, and when you get to the Custom Install stage, make sure that the box UNIX Dev Support is checked, as shown in Figure 1.2. Continue with the installation. |