Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

Working With Resources

CodeWarrior and Xcode both work with Resource Manager .r and .rsrc resource files. In CodeWarrior, you can set Rez Options, Derez Options, and Common Options in the Rez target settings pane. In Xcode, you can set Resource Manager settings in the Build pane of a target inspector window. If you drag resources into your Xcode project, or import them as part of a CodeWarrior project, Xcode should place those resources in the Build ResourceManager Resources build phase. Xcode compiles .r files in this build phase and copies any .rsrc files into the product bundle. For more information on build phases in Xcode, see Build Phases in Xcode User Guide.

Xcode does not provide a user interface to rez and derez individual files, but the Rez and DeRez tools are available in /Developer/Tools and you can run them from the command line and in scripts. There are man pages for Rez and DeRez, but documentation for the rez language is a bit hard to find. It’s documented in Appendix C of Building and Managing Programs with MPW.

Important: Due to a bug in Rez, if output is written to a data-fork file (as it almost always is when building with Xcode), then all .rsrc files included with an include statement must also be data-fork files.

In Mac OS X and for Carbon applications generally, resources should be put in the data fork of a separate resource file, not in the resource fork of the executable, as described in the section "Move Resources to Data Fork–Based Files" in Carbon Porting Guide. The primary reason for moving application resources out of resource forks is to enable applications to be seamlessly moved around different file systems without loss of their resources.

In addition to using .r and .rsrc files for resources, Carbon applications can use Interface Builder resource files (called nib files because they have an extension of .nib). When you create a new project in Xcode, the Carbon Application project template creates a nib-based Carbon application. Interface Builder provides an easy-to-use graphical method for designing and implementing a GUI, so there is potentially a lot to gain by using nib files for your resources. Interface Builder is described in “Companion Applications.” To learn more about using Interface Builder with Carbon applications, see Interface Builder, Unarchiving Interface Objects With Interface Builder Services and Interface Builder Services Reference.

Mac OS X also provides a very useful mechanism for storing language-dependent resources in localized directories within an application or other bundle. By using APIs such as CFBundle, your application can work with localized resources in a seamless manner. For more information on resources, application packaging, and bundles, see the document Mac OS X Technology Overview, as well as the document Bundle Programming Guide.



< Previous PageNext Page > Hide TOC


Last updated: 2006-10-26




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice