Learning Cocoa with Objective-C and December 2002 Tools Release

by James Duncan Davidson

Recently, I've received a spate of inquiries about a particular problem that readers of Learning Cocoa are having when building projects that contain a space in their name. Unfortunately, there are several projects in Learning Cocoa including some of the first applications in the book like Hello World and Currency Converter. You'll know you've run into it when you see an error like the following show up:

missing file or directory Hello

missing file or directory World_Prefix.h

Why is this happening? Well, it's because the December 2002 Tools release introduced support for Precompiled Headers. This is a feature that makes life better by shortening compile times after the first and is a welcome addition to Project Builder. However, there's a bug in that the project creation templates don't put quote marks around the file name when setting up the precompiled header settings. There are two possible solutions, both easy:

  • Name your projects without spaces in them

  • Edit the target settings. To do this, select the current target, go into Settings -> Simple View ->GCC Compiler Settings, and then put quote marks around the file name in the Prefix Header box.

I've pestered my contacts at Apple and they are indeed aware of the problem. Hopefully, once we see a new version of the developer tools, the answer will be simply "Go to the ADC site and upgrade your tools!" Until then, use either of the above options and you'll be good to go.