Questions that I see new Mac OS X developers (coming either from Windows/Linux, or just new Carbon developers in general) ask:
Q: How do I get the location of the application / CWD?
- A: CWD (current working directory) is Mostly Useless. If your application is bundled (see [Apple's Docs describing Bundles]) you'll want to use CFBundleCopyExecutableURL or CFBundleCopyBundleURL, depending on exactly what you mean by "location of the application" (see [this wiki's CFBundle page] for example code).
- However, you'll normally want to avoid this. It's recommended that application data live in your application bundle's "Resources" folder, which you can access using CFBundleCopyResourceURL(), or if it needs to be editable, needs to be extracted or is an optional install, in the user's Application Support folder in their Library folder.
Q: I built my Carbon application from a Makefile, now when I try to run it I don't see a menu bar (or can't bring windows to the front)
- A: You must create a bundle for your application. The recommended route for Mac OS X development is XCode, Apple's free IDE. If you really want to use Makefiles to make your project, you can use a Makefile. Although a little wxWidgets specific, one is available from [the wxWidgets forums]
Q: I'm trying to build for Mac OS X 10.2 (or OS 9), and....
- A: Normal Mac development wisdom says to develop for the current version of the OS, and the previous version. A 10.N revision of Mac OS X is released about once every 12-18 months and most users (or at least most users that buy software) seem to keep up to date. There have been [statistics gathered] by the [Omni Group], longtime commercial Mac OS X developers.
- OS 9 was [declared dead in 2002]. Unless you have a very good reason you don't want to develop for it. The Carbon interfaces for OS 9 haven't been updated since, so many newer Carbon APIs aren't available. In addition, the major compiler for the OS 9 era, [Codewarrior] is no longer available for the Mac.
Q: Where is the current working directory set when you run your application?
- A: There are two concepts of working directory in the Mac OS, one for the File Manager (get and set by HGetVol and HSetVol) and one for BSD (get and set by getcwd and chdir). For a discussion of the latter case, see: [Where's my File?] Also, contains a snippet on how to set your working directory.