I N S I D E M A C O S X System Overview February 2001 Apple Computer, Inc. AirPort, Carbon, Cocoa, iBook, iMac, Some states do not allow the exclusion or © 2000-2001 Apple Computer, Inc. Power Mac, Quartz, and Velocity En- limitation of implied warranties or liabil- All rights reserved. gine are trademarks of Apple Com- ity for incidental or consequential damag- puter, Inc. es, so the above limitation or exclusion No part of this publication may be re- produced, stored in a retrieval sys- Enterprise Objects, Enterprise Objects may not apply to you. This warranty gives tem, or transmitted, in any form or by Framework, NeXT, Objective-C, and you specific legal rights, and you may any means, mechanical, electronic, OpenStep are registered trademarks also have other rights which vary from photocopying, recording, or other- of NeXT Software, Inc., registered in state to state. wise, without prior written permis- the United States and other countries. sion of Apple Computer, Inc., with Java and all Java-based trademarks the following exceptions: Any person are trademarks or registered trade- is hereby authorized to store docu- marks of Sun Microsystems, Inc., in mentation on a single computer for the United States and other countries. personal use only and to print copies Netscape Navigator is a trademark of of documentation for personal use Netscape Communications Corpora- provided that the documentation tion. contains Apple’s copyright notice. OpenGL is a registered trademark of The Apple logo is a trademark of Ap- Silicon Graphics, Inc. ple Computer, Inc. PostScript is a trademark of Adobe Use of the “keyboard” Apple logo Systems Incorporated. (Option-Shift-K) for commercial pur- poses without the prior written con- PowerPC is a trademark of Interna- sent of Apple may constitute tional Business Machines Corpora- trademark infringement and unfair tion, used under license therefrom. competition in violation of federal Simultaneously published in the and state laws. United States and Canada No licenses, express or implied, are Even though Apple has reviewed this granted with respect to any of the manual, APPLE MAKES NO WARRAN- technology described in this book. TY OR REPRESENTATION, EITHER EX- Apple retains all intellectual property PRESS OR IMPLIED, WITH RESPECT rights associated with the technology TO THIS MANUAL, ITS QUALITY, AC- described in this book. This book is CURACY, MERCHANTABILITY, OR intended to assist application devel- FITNESS FOR A PARTICULAR PUR- opers to develop applications only for POSE. AS A RESULT, THIS MANUAL IS Apple-labeled or Apple-licensed SOLD “AS IS,” AND YOU, THE PUR- computers CHASER, ARE ASSUMING THE EN- TIRE RISK AS TO ITS QUALITY AND Every effort has been made to ensure ACCURACY. that the information in this document is accurate. Apple is not responsible IN NO EVENT WILL APPLE BE LIABLE for typographical errors. FOR DIRECT, INDIRECT, SPECIAL, IN- Apple Computer, Inc. CIDENTAL, OR CONSEQUENTIAL 1 Infinite Loop DAMAGES RESULTING FROM ANY Cupertino, CA 95014 DEFECT OR INACCURACY IN THIS 408-996-1010 MANUAL, even if advised of the possi- bility of such damages. Apple, the Apple logo, AppleScript, AppleShare, AppleTalk, Col- THE WARRANTY AND REMEDIES SET orSync,Finder, FireWire, Mac, Macin- FORTH ABOVE ARE EXCLUSIVE AND tosh, QuickDraw, QuickTime, IN LIEU OF ALL OTHERS, ORAL OR PowerBook, and TrueType are trade- WRITTEN, EXPRESS OR IMPLIED. marks of Apple Computer, Inc., regis- No Apple dealer, agent, or employee is tered in the United States and other authorized to make any modification, ex- countries. tension, or addition to this warranty. Contents Figures, Listings, and Tables 11 Chapter 1 About This Book 15 Why Read This Book 15 Further Investigations 17 Installed Developer Documentation 17 Other Apple Publications 19 Information on BSD 19 Other Information on the Web 19 Chapter 2 System Technologies 21 The User Experience 22 Aqua 23 The Finder 24 Application Support 26 Multiple Users 27 Internationalization 28 Application Extensibility 28 Exported Application Services 29 Other Parts of the User Experience 30 Darwin 30 Mach 31 BSD 32 Device-Driver Support 32 Networking Extensions 33 File Systems 33 Darwin and Open Source Development 35 Graphics and Imaging 35 Quartz 36 QuickDraw 37 3 Apple Computer, Inc. February 2001 C O N T E N T S OpenGL 38 QuickTime 38 Printing 39 Apple Type Solution 40 Networking and the Internet 41 Media Types 41 Standard Protocols 42 Legacy Network Services and Protocols 43 Routing and Multihoming 43 Personal File and Web Services 43 Advanced Hardware Features 44 USB 44 FireWire 45 Velocity Engine 45 AirPort 45 Chapter 3 System Architecture 47 A Layered Perspective 48 Application Environments 53 Carbon 53 Cocoa 56 Java 57 The Graphics and Windowing Environment 60 Core Graphics Services 62 Core Graphics Rendering 63 The Printing System 65 The User Interface of the Printing System 66 Summary of Printing Architecture 67 Printer Discovery 69 The Printing Process 69 Other Application Services 70 Process Manager 70 Carbon Event Manager 71 Apple Events 71 The Clipboard 71 4 Apple Computer, Inc. February 2001 C O N T E N T S Core Services 72 Carbon Managers 72 Core Foundation 74 Open Transport 76 Tracking a User Event 77 Chapter 4 Booting and Logging In 81 The Boot Sequence 81 BootROM 82 BootX 82 Kernel Initialization 83 System Initialization 83 The rc.boot and rc Scripts 84 Startup Items 84 The Login Procedure 87 Authenticating Users 88 Setting Up the User Environment 89 Launching the Finder and the Dock 89 System Daemons 90 Logging Out and System Shutdown 92 Customization Techniques 94 Customizing Booting Behavior 95 Customizing the Login Procedure 97 Chapter 5 Bundles 101 Benefits of Using Bundles 102 Anatomy of a Bundle 103 The Finder and Bundles 108 Types of Bundles 109 An Application’s Main Bundle 110 Framework Bundles 110 Loadable Bundles and Dynamic Linking 110 Localized Resources 111 Localized Character Strings 112 5 Apple Computer, Inc. February 2001 C O N T E N T S Search Algorithm 113 Bundles and the Resource Manager 115 Chapter 6 Application Packaging 117 An Application Is a Bundle 117 Application Frameworks, Libraries, and Helpers 119 Private Frameworks 120 Shared Frameworks and the Central Directory 121 Other Shared Application Code 122 Applications and Loadable Bundles 123 User Resources in Applications 124 Application Help 124 Application Preferences 125 Document Resources 126 Chapter 7 Frameworks 127 The Framework as a Library Package 128 The Internal Structure of Frameworks 129 Standard Locations for Frameworks 131 Dynamic Shared Libraries 132 Framework Versioning 134 Major Versions 135 Minor Versions 136 Versioning Summary and Guidelines 137 Chapter 8 Umbrella Frameworks 141 Kinds of Frameworks 142 The Purpose of Umbrella Frameworks 143 Linking and Including Guideline 145 The Structure of an Umbrella Framework 146 Restrictions on Subframework Linking 148 6 Apple Computer, Inc. February 2001 C O N T E N T S Chapter 9 The File System 151 How the File System Is Organized 151 File-System Domains 153 The System and Local Domains 154 Directories of the Classic Environment 156 The User Domain 157 The Network Domain 161 The Library Directory 162 The Developer Directory 164 Searching Within the File-System Domains 166 Differences Between HFS+ and UFS 167 Aliases and Symbolic Links 168 Resource Forks 170 File Encodings and Fonts 172 Chapter 10 The Finder 175 The Role of the Finder 175 Finder Interfaces to Applications 177 Information Property Lists 177 Information Stored by the Finder 178 Collecting Application Information 178 The Desktop Folder 179 Finder Attributes 179 The Handling of Applications and Documents 180 The Finder and File Operations 181 Copy and Move Operations 182 Management of Aliases and Symbolic Links 183 Chapter 11 Software Configuration 185 Property Lists 185 Information Property Lists 186 Document Configuration 187 An Example of an Information Property List 188 Standard Keys 191 7 Apple Computer, Inc. February 2001 C O N T E N T S Finder Keys 193 Application Package Keys 195 Launch Services Keys 197 The Preferences System 197 How Preferences Are Stored 198 Preference Domains 199 The defaults Utility 200 Chapter 12 Internationalization 203 Internationalizing Your Application 204 Language Preferences and Bundle Resources 205 Designating Languages and Locales 207 Tools for Internationalization and Localization 208 Localizing User Interfaces 211 Localizing Strings 212 Composing a Strings File 212 Generating Strings Files 214 Adding Multiscript Support 215 Chapter 13 Installation and Integration 219 Preparing Software for Mac OS X 219 Applications and Documents FAQ 220 What metadata must I specify for an application? 220 Must I package my CFM executable in a bundle? 221 How should I store application resources? 221 How do I indicate document types in Mac OS X? 223 Can I treat my plug-ins as documents? 223 How does the Finder handle documents? 223 Why even have extensions? 224 How should my application save documents? 225 CFM Executables 225 User Interface Issues 228 Icons 229 Custom Controls and System Appearance 229 Carbon Nib Files 230 8 Apple Computer, Inc. February 2001 C O N T E N T S Ownership and Permissions 230 Overview of BSD Permissions 231 File Permissions on Mac OS X 233 Permissions for Applications and Documents 234 The Classic Environment and Your Application 235 Overview of the Classic Environment 236 Compatibility With Native Mac OS 9 236 Device Support 237 Integration With Mac OS X 238 User Interface 238 The Classic Environment and File Systems 239 Extensions and Preferences 240 The Finder and the Desktop 240 Networking and Printing 241 Other Classic Integration Issues 242 Installing Your Application 242 Where to Install 242 Manual Installation 243 Installers 244 Installation Packages 246 Creating an Installation Package 246 System-Wide Resources 250 Chapter 14 Issues and Options With Multiple Environments 251 Tasks and Processes 251 Threading Packages 252 Layering Details 254 Usage Guidelines 254 Interprocess Communication 255 Communicating With Apple Events 256 Broadcasting Simple Notifications 257 Transferring Raw Data With CFMessagePort 257 Communicating With BSD Sockets 257 Communicating With BSD Pipes 258 Handling Exceptions With BSD Signals 259 Sharing Large Resources With Shared Memory 259 9 Apple Computer, Inc. February 2001 C O N T E N T S Making Services Available to Other Applications 260 Calling Other Processes With Distributed Objects 260 Messaging With the Mach Port Object 260 Library Managers and Executable Formats 261 Comparing the Runtime Environments 261 CFM and dyld 262 PEF and Mach-O 262 Code-Generation Models 262 Vector Libraries 263 CFM Executable and Non-Carbon APIs 264 Should You Use CFM or dyld? 264 Glossary 267 Index 281 10 Apple Computer, Inc. February 2001