You are previewing Step into Xcode Mac OS X Development.
O'Reilly logo
Step into Xcode Mac OS X Development

Book Description

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.

Coverage includes

  • 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.



    Table of Contents

    1. Copyright
      1. Dedication
    2. Preface
      1. Audience
      2. Structure of the Book
      3. Xcode Versions Covered
      4. Typographical Conventions
    3. Acknowledgments
    4. I. The Life Cycle of a Mac OS X Application
      1. 1. Kicking the Tires
        1. 1.1. First Run
        2. 1.2. Hello, World
        3. 1.3. What Went Where
        4. 1.4. Summary
      2. 2. Simple Workflow and Passive Debugging
        1. 2.1. Linear Regression
        2. 2.2. Plan of Action
        3. 2.3. A Command Line Tool
        4. 2.4. Build Errors
        5. 2.5. Simple Debugging
        6. 2.6. Summary
      3. 3. Simple Active Debugging
        1. 3.1. The Next Step
        2. 3.2. Active Debugging
        3. 3.3. Summary
      4. 4. Compilation: The Basics
        1. 4.1. Compiling
        2. 4.2. Linking
        3. 4.3. Dynamic Loading
        4. 4.4. Prebinding
        5. 4.5. ZeroLink
        6. 4.6. Summary
      5. 5. Starting a Cocoa Application
        1. 5.1. Plan of Action
          1. 5.1.1. Program Tasks
          2. 5.1.2. Model-View-Controller
            1. The Model
            2. The Controller
            3. The View(s)
        2. 5.2. Starting a New Project
        3. 5.3. Implementation: Model
          1. 5.3.1. DataPoint
          2. 5.3.2. Regression Model Class
          3. 5.3.3. Model: Done
        4. 5.4. Summary
      6. 6. A Cocoa Application: Views
        1. 6.1. Interface Builder
        2. 6.2. Layout
        3. 6.3. Sizing
        4. 6.4. A Split View
        5. 6.5. Summary
      7. 7. A Cocoa Application: Controllers
        1. 7.1. Still in Interface Builder
        2. 7.2. NSObjectController: Document
        3. 7.3. NSObjectController: Model
        4. 7.4. NSArrayController: DataPoints
        5. 7.5. Value Binding
        6. 7.6. Actions and Outlets
        7. 7.7. MyDocument
        8. 7.8. Application Properties
        9. 7.9. Building
        10. 7.10. Summary
      8. 8. Property Lists
        1. 8.1. Data Types
        2. 8.2. Property List Files
          1. 8.2.1. Writing a Property List
            1. Model
            2. View
            3. Controller
          2. 8.2.2. Examining Property Lists
            1. As Text
            2. Property List Editor
        3. 8.3. Other Formats
          1. 8.3.1. ASCII Property Lists
          2. 8.3.2. Binary Property Lists
        4. 8.4. Text Macros
        5. 8.5. Summary
      9. 9. Libraries and Dependent Targets
        1. 9.1. Adding a Target
        2. 9.2. Library Design
        3. 9.3. Modifying Linear
        4. 9.4. A Dependent Target
        5. 9.5. Examining the Library
        6. 9.6. Running the Library
        7. 9.7. Summary
      10. 10. File Packages and Bundles
        1. 10.1. A Simple Package: RTFD
        2. 10.2. Bundles
        3. 10.3. Application Bundles
        4. 10.4. The Info.plist File
          1. 10.4.1. Keys for All Bundles
            1. Info
            2. Localization
            3. Structure
          2. 10.4.2. Keys for Applications
            1. Documents and URLs
            2. Help
            3. Info
            4. Launch Behavior
            5. Localization
            6. Structure
          3. 10.4.3. Keys for Plug-Ins
          4. 10.4.4. Keys for Java
          5. 10.4.5. Keys for Preference Panes
          6. 10.4.6. Keys for Dashboard Widgets
            1. Layout
            2. Security
            3. Structure
        5. 10.5. Summary
      11. 11. Creating a Custom View
        1. 11.1. Controller
        2. 11.2. View
        3. 11.3. The Delegate Design Pattern
        4. 11.4. The Custom View
        5. 11.5. Showing the Window
        6. 11.6. Testing
        7. 11.7. Debugging a View
        8. 11.8. Summary
      12. 12. Dynamic Libraries and Frameworks
        1. 12.1. Adding a Framework Target
        2. 12.2. Framework Structure
        3. 12.3. Using the Framework
        4. 12.4. Where Frameworks Go
        5. 12.5. Private Frameworks
        6. 12.6. Prebinding
        7. 12.7. Summary
      13. 13. Version Control
        1. 13.1. Setting up a Repository
        2. 13.2. Controlling Linear
        3. 13.3. Long Live Linear
        4. 13.4. Tagging
        5. 13.5. Summary
      14. 14. Cross-Development
        1. 14.1. Cross-Development SDKs
        2. 14.2. Nib Compatibility
        3. 14.3. NSTableDataSource
        4. 14.4. Add, Remove, Compute, and Graph Buttons
        5. 14.5. Run and Archive
        6. 14.6. A More Sophisticated Approach
        7. 14.7. Producing a Universal Binary
          1. 14.7.1. Auditing for Portability
          2. 14.7.2. Auditing Linear
          3. 14.7.3. Building Universal
          4. 14.7.4. Mixing SDKs
        8. 14.8. Summary
      15. 15. Using the Data Modeling Tools
        1. 15.1. Data Modeling
        2. 15.2. Revisiting the Model
          1. 15.2.1. DataPoint
            1. All DataPoints
            2. Initializers
            3. Accessors
          2. 15.2.2. Regression
          3. 15.2.3. MyDocument
        3. 15.3. Interface Builder
        4. 15.4 Build and Run
        5. 15.5. Adding an Entity
          1. 15.5.1. Adding to the Data Model
          2. 15.5.2. Human Interface
          3. 15.5.3. First Run
          4. 15.5.4. One More Table
        6. 15.6. Summary
      16. 16. Spotlight
        1. 16.1. How Data Gets into Spotlight
        2. 16.2. Uniform Type Identifiers
        3. 16.3. The Metadata Plug-In
          1. 16.3.1. MetaLinear Project Files
            1. Info.plist
            2. schema.xml
            3. schema.strings
            4. GetMetadataForFile.c
          2. 16.3.2. Packaging the Plug-In
        4. 16.4. Core Data and Metadata
        5. 16.5. The Proof of the Pudding
        6. 16.6. Summary
      17. 17. Finishing Touches
        1. 17.1. Trimming the Menus
        2. 17.2. Avoiding Singularity
        3. 17.3. Localization
          1. 17.3.1. Credits.rtf
          2. 17.3.2. MainMenu.nib
          3. 17.3.3. MyDocument.nib
          4. 17.3.4. GraphWindow.nib
          5. 17.3.5. InfoPlist.strings
          6. 17.3.6. Trying It Out
          7. 17.3.7. Localizable.strings
        4. 17.4. Checking Memory Usage
        5. 17.5. The Release Build Configuration
        6. 17.6. Dead-Code Stripping
        7. 17.7. xcodebuild
        8. 17.8. Summary
    5. II. Xcode Tasks
      1. 18. Navigating an Xcode Project
        1. 18.1. Editor Panes
          1. 18.1.1. Jumps
          2. 18.1.2. Code Sense
          3. 18.1.3. Navigation Bar
          4. 18.1.4. Editor Modes
        2. 18.2. Project Find Window
        3. 18.3. The Favorites Bar
        4. 18.4. Groups & Files List
          1. 18.4.1. The Project Group
          2. 18.4.2. The Targets Group
          3. 18.4.3. The Executables Group
          4. 18.4.4. Smart Groups
          5. 18.4.5. Symbol Smart Group
        5. 18.5. Class Browser Window
        6. 18.6. Class Modeler
        7. 18.7. Project Layout
          1. 18.7.1. Default Layout
            1. Build Results
            2. Run Log
            3. SCM Results
          2. 18.7.2. All-in-One Layout
            1. Editing
            2. Building
            3. Debugging
          3. 18.7.3. Condensed Layout
        8. 18.8. Summary
      2. 19. Xcode for CodeWarrior Veterans
        1. 19.1. Losses
          1. 19.1.1. Speed
          2. 19.1.2. Syntax Coloring
          3. 19.1.3. Debugging Templates
          4. 19.1.4. RAD Tools
        2. 19.2. Make Yourself at Home
          1. 19.2.1. The Project Window
          2. 19.2.2. Key Mapping
          3. 19.2.3. Build Behavior
          4. 19.2.4. Window Behavior
        3. 19.3. Converting a CodeWarrior Project
          1. 19.3.1. Importing the Project
          2. 19.3.2. Targets and Configurations
            1. For Consolidating Targets
            2. Against Consolidating Targets
        4. 19.4. Traps in Conversion
        5. 19.5. Exporting Symbols
          1. 19.5.1. #pragma export
          2. 19.5.2. Another Way
        6. 19.6. Summary
      3. 20. Xcode for make Veterans
        1. 20.1. Xcode Build Variables
        2. 20.2. Custom Build Rules
        3. 20.3. Run Script Build Phase
        4. 20.4. Under the Hood: A Simple Build
          1. 20.4.1. Copy Structural Files
          2. 20.4.2. Copy Bundle Resources
          3. 20.4.3. Compile Sources
          4. 20.4.4. Linkage (First Architecture)
          5. 20.4.5. Compile Sources (Second Architecture)
          6. 20.4.6. Linkage (Second Architecture)
          7. 20.4.7. Create Universal Binary
          8. 20.4.8. Compile Data Models
          9. 20.4.9. Finishing Touch
        5. 20.5. The xcodebuild Tool
        6. 20.6. Settings Hierarchy
        7. 20.7. Build Configurations
        8. 20.8. Summary
      4. 21. More About Debugging
        1. 21.1. Debugging Techniques
        2. 21.2. Printing Values
        3. 21.3. Custom Formatters
        4. 21.4. Breakpoint Commands
        5. 21.5. Breakpoint Conditions
        6. 21.6. Lazy Symbol Loading
        7. 21.7. Zombies
          1. 21.7.1. Released-Pointer Aliasing
          2. 21.7.2. Zombies in Cocoa
          3. 21.7.3. Zombies in Core Foundation
        8. 21.8. Summary
          1. Further Reading
      5. 22. Xcode and Speed
        1. 22.1. Precompiled Headers
        2. 22.2. Predictive Compilation
        3. 22.3. Distributed Builds
        4. 22.4. ZeroLink
        5. 22.5. Project Indexing
        6. 22.6. Summary
      6. 23. AppleScript Studio
        1. 23.1. An AppleScript Application
        2. 23.2. Unit Testing
          1. 23.2.1. Adding OCUnit
          2. 23.2.2. Test Cases
          3. 23.2.3. Testing Options
        3. 23.3. Summary
      7. 24. A Large Project
        1. 24.1. Graphviz
        2. 24.2. Preparing the Project
        3. 24.3. An External Build Project
        4. 24.4. Debugging a Custom Executable
        5. 24.5. Performance
        6. 24.6. A Better Way to Include Files
          1. 24.6.1. The Script
          2. 24.6.2. Building the Project Index
          3. 24.6.3. Compromising with AppleScript
        7. 24.7. Summary
      8. 25. Closing Snippets
        1. 25.1. Miscellaneous Traps
        2. 25.2. Miscellaneous Tips
        3. 25.3. Documentation
          1. 25.3.1. The Documentation Window
          2. 25.3.2. Documentation Updates
    6. A. Installing Xcode
      1. A.1 Apple Developer Connection
        1. A.1.1 Downloading from ADC
      2. A.2 Setting up the Dock
    7. B. Some Build Variables
      1. B.1 Useful Build Variables
      2. B.2 Splitting Build Variables
      3. B.3 Source Trees
    8. Glossary
    9. CD-ROM Warranty