A Step-by-Step Guide to the Xcode Mac OS Development Environment
Every copy of Mac OS X comes with Xcode, the powerful development suite that Apple uses to build applications ranging from Safari to iTunes. But because Xcode is complex and subtle, even experienced Mac programmers rarely take full advantage of it. Now, Mac developer Fritz Anderson has written the definitive introduction and guide to using Xcode to build applications with any Macintosh technology or language.
Anderson helps you master Xcode's powerful text editor, industry-standard gcc compiler, graphical interactive debugger, mature UI layout and object linkage editor, and exceptional optimization tools. One step at a time, you'll develop a command-line utility, then use Xcode tools to evolve it into a full-fledged Cocoa application. Anderson provides expert guidance on development frameworks, source code management, Core Data modeling, localization, and much more.
- Understanding Xcode workflow and the Mac OS X application lifecycle
- Porting established legacy projects into Xcode
- Using the Model-View-Controller design pattern to build robust graphical applications
- Building static libraries and working with Xcode's build system
- Making the most of bundles and package directories
- Creating applications compatible with older versions of Mac OS X
- Creating universal binaries to run on both Intel and PowerPC Macintoshes
- Adding Spotlight searchability to data files
- Leveraging Xcode's built-in support for unit testing
- Using Xcode on makefile-based UNIX development projects
Step Into Xcode's breadth, depth, and practical focus make it indispensable to every Mac developer: current Xcode users upgrading to Xcode 2.1, experienced Mac programmers migrating from CodeWarrior, UNIX/Linux programmers moving to Mac OS X, and even novices writing their first programs or scripts.
Über den Autor und weitere Mitwirkende
Prolog. Abdruck erfolgt mit freundlicher Genehmigung der Rechteinhaber. Alle Rechte vorbehalten.
From the moment it first published Mac OS X, Apple Computer has made a complete suite of application-development tools available to every Macintosh user. Since Mac OS X version 10.3, those tools have been led by Xcode, the development environment that Apple's engineers use to develop system software and such applications as Safari, iTunes, Mail, and iChat. These same tools are in your hands.
- A solid text editor with syntax coloring and API-based code completion
- The industry-standard gcccompiler suite
- A graphical, interactive debugger based on the GNU debugger (gdb)
- A mature human interface (UI) layout and object-linkage editor for Carbon and Cocoa
- Tools for gaining detailed insights into optimizing performance
I wrote this book for three types of readers.
1. Newcomers curious about the world of Mac OS X development
2. Experienced UNIX-family operating systems users who want an introduction to the Mac OS X tool set
3. Xcode users wanting to supplement their techniques
Step into Xcode will not attempt to teach programming, a programming language, or any of the Mac OS X programming frameworks; good books on those subjects have already been written. My aim is to focus squarely on using the Xcode tool set. Most of the book uses one example project--not as a showcase for the programming techniques involved but as a framework for how to do Mac development with these tools.
The CD-ROM accompanying this book provides the complete project directory--bugs and all!--for each chapter. Many of the examples in this book follow the progress of an application project that begins with a UNIX command line tool and progresses to a Core Data-based application with Spotlight support. As you follow along, you won't have to peck out every file and setting yourself. The CD-ROM directory, Examples, includes a copy of the project at every major stage of development--at least one version for each chapter. You can simply copy the current example project to your hard drive; the only errors are the ones I made deliberately.
Structure of the Book
Step into Xcode is divided into two parts. Part I introduces Xcode and Mac OS X development against the background of developing a simple application from a BSD command line tool to a Tiger-savvy Cocoa application taking advantage of Core Data and Spotlight.
Chapter 1 introduces Xcode with the obligatory "Hello, World" demonstration.
Chapter 2 demonstrates the typical Xcode workflow by building a command line tool that will form the heart of the application we'll be building throughout Part I.
Chapter 3 moves from passive use of the Xcode debugger to active use, interrupting program flow to examine the workings of a flawed application.
Chapter 4 shows what happens in compilation and linkage, both generally and in Mac OS X.
Chapters 5, 6, and 7 wrap our command line tool in a Cocoa graphical interface. The Model-View-Controller design pattern is matched to the tools Xcode provides to implement it.
Chapter 8 focuses on property lists, a must-know subject in Mac OS X development, and shows how to create text macros for Xcode.
Chapter 9 moves our command line tool into a static library, showing how to build such a library and how to integrate a dependent target with Xcode's build system.
Chapter 10 examines bundles and package directories. Most of the targets Xcode can produce are varieties of bundles. We look at the ubiquitous Info.plist file.
Chapter 11 develops techniques for creating custom view classes for Cocoa and shows how the development tools support them.
Chapter 12 extends the odyssey of our library from library to framework, showing how to package a dynamic library and its headers for sharing or for embedding in an application.
Chapter 13 surveys the Xcode options in support of source code management systems. We set up a local CVS (concurrent versions system) repository and put our project under SCM (software configuration management) control.
Chapter 14 covers two scenarios for cross-development: creating applications compatible with versions of Mac OS X earlier than your own and creating universal binaries to run on both Intel and PowerPC Macintoshes.
Chapter 15 shows how to use the data modeling tool to generate a Core Data model for our application. After converting our application to use Core Data, many development tasks become a matter of using Interface Builder.
Chapter 16 examines the techniques used to add Spotlight searchability to our data files.
Chapter 17 finishes up our application with a localization and offers some thoughts on dead-code stripping.
Part II goes deeper into Xcode usage.
Chapter 18 examines the Xcode human interface and explains how to use it to navigate projects.
Chapter 19 considers Xcode from the point of view of a developer accustomed to using CodeWarrior, examining the stumbling blocks on the way to conversion and showing how to make the Xcode experience more familiar. At the end of the chapter, the notes on controlling the export of symbols may be useful to non-CodeWarriors.
Chapter 20 looks at Xcode from the point of view of a developer accustomed to working with make files. This chapter describes the build system beneath the IDE (interactive development environment) and explains how you can customize and control it.
Chapter 21 goes deeper into the debugging tools and techniques introduced in Part I.
Chapter 22 shows how to make Xcode work faster.
Chapter 23 builds a simple AppleScript Studio application and considers Xcode's built-in support for unit testing.
Chapter 24 shows how to use Xcode on a large open-source make file-based project, and how to apply Xcode's debugger and the Shark performance measurement tool to it.
Chapter 25 offers tips, traps, and observations that were left over from the rest of the book.
Finally, there are two appendixes:
Appendix A reviews how to get the latest version of Xcode and how to install it.
Appendix B lists the major settings variables used by the Xcode build system.
Xcode Versions Covered
This book is based on Xcode version 2.1, released in June 2005, although this version will probably vary from the one you will use, as Apple has not been timid about reworking Xcode substantially as performance and usability issues arise. The overall strategies and approach developed in this book--the Xcode workflow--will be the same across Xcode versions. For details, you may have to explore Xcode's menus, inspectors, and preferences; search its help system; or ask on Apple's mailing list for Xcode users: http://lists.apple.com/mailman/listinfo/xcode-users. Most of the material in this book can also be applied to Xcode 1.5, the last version of Xcode for Mac OS X 10.3.