3.4. Building and Running

After you have written a reasonable amount of code, the urge to build your project may strike. Building your project is the first step toward validating that you have entered your code correctly. Of course, compiling does not guarantee your program actually works! Remember: computers only understand what you said, not what you meant. Once you build your project, however, you can run your program and make sure it does what you want.

In the next Try It Out example, you actually build the Calculator project you saw earlier. Along the way, you correct a few build errors introduced during the editing process. Finally, you verify that Calculator works correctly by running the program and testing its results.

3.4.1.

3.4.1.1. Try It Out: Building Your Calculator Project
  1. In Xcode, open your Calculator project you created and saved earlier.

  2. Click the Build button. If you entered the code exactly as it was provided earlier, the project will fail to compile. The project window's status area notes that the build failed, and the Errors and Warnings group appears drawn in red.

  3. Select the Errors and Warnings group. The file area changes to display a list of build errors, resembling Figure 3-13.

    Figure 3.13. Figure 3-13
  4. Double-click the first error in the list. A source editor appears with the contents of main.c. A line of code is selected near where the error occurred, ...

Get Beginning Mac OS® X Programming 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.