Xcode 5 Start to Finish: iOS and OS X Development

Book description

Use Xcode 5 to Write Great iOS and OS X Apps!


Xcode 5 Start to Finish will help you use the tools in Apple’s Xcode 5 to improve productivity, write great code, and leverage the newest iOS 7 and OS X Mavericks features.


Drawing on thirty years of experience developing for Apple platforms and helping others do so, Fritz Anderson shows you a complete best-practice Xcode workflow. Through three full sample projects, you’ll learn to integrate testing, source control, and other key skills into a high-efficiency process that works.


Anderson shows you better ways to storyboard, instrument, build, and compile code, and helps you apply innovations ranging from Quick Look to Preview Assistant. By the time you’re finished, you’ll have the advanced Xcode skills to develop outstanding software.


Coverage includes

  • Setting breakpoints and tracing execution for active debugging

  • Creating libraries by adding and building new targets

  • Integrating Git or Subversion version control

  • Creating iOS projects with MVC design

  • Designing Core Data schemas for iOS apps

  • Linking data models to views

  • Designing UI views with Interface Builder

  • Using the improved Xcode 5 Autolayout editor

  • Improving reliability with unit testing

  • Simplifying iOS provisioning

  • Leveraging refactoring and continual error checking

  • Using OS X bindings, bundles, packages, frameworks, and property lists

  • Localizing your apps

  • Controlling how Xcode builds source code into executables

  • Analyzing processor and memory usage with Instruments

  • Integrating with Mavericks Server’s sleek continuous integration system

  • Register your book at www.informit.com/register for access to this title’s downloadable code.

    Table of contents

    1. About This eBook
    2. Title Page
    3. Copyright Page
    4. Dedication Page
    5. Contents at a Glance
    6. Contents
    7. Acknowledgments
    8. About the Author
    9. Introduction
      1. How This Book Is Organized
        1. First Steps
        2. The Life Cycle of an iOS Application
        3. Xcode for Mac OS X
        4. Xcode Tasks
        5. Appendixes
      2. About Versions
      3. About the Code
      4. Conventions
    10. Part I: First Steps
      1. 1. Getting Xcode
        1. Before You Begin
          1. Developing for Earlier Operating Systems
          2. Requirements
        2. Installing Xcode
          1. Command-Line Tools
        3. Removing Xcode
        4. Apple Developer Programs
        5. Downloading Xcode
        6. Additional Downloads
        7. Summary
      2. 2. Kicking the Tires
        1. Starting Xcode
        2. Hello World
          1. A New Project
          2. Quieting Xcode Down
          3. Building and Running
          4. The Real Thing
        3. Getting Rid of It
        4. Summary
      3. 3. Simple Workflow and Passive Debugging
        1. Creating the Project
        2. Building
        3. Running
        4. Simple Debugging
        5. Summary
      4. 4. Active Debugging
        1. A Simple Test Case
        2. Going Active
          1. Setting a Breakpoint
          2. The Variables Pane
          3. Stepping Through
        3. Fixing the Problem
          1. Behaviors
          2. The Fix
        4. Summary
      5. 5. Compilation
        1. Compiling
        2. Linking
        3. Dynamic Loading
        4. Xcode and Clang
          1. Local Analysis
          2. Cross-Function Analysis
          3. Indexing
        5. Compiler Products
          1. Intermediate Products
          2. Precompilation
        6. Summary
      6. 6. Adding a Library Target
        1. Adding a Target
          1. Targets
        2. Target Membership
          1. Adding Files to a Target
          2. Headers in Targets
        3. A Dependent Target
          1. Adding a Library
          2. Debugging a Dependent Target
        4. Summary
      7. 7. Version Control
        1. Taking Control
          1. Creating a Git Repository by Hand
        2. The State of Your Files
          1. How Xcode Works with Git
        3. Your First Commit
        4. Working with Remote Repositories
          1. Cloning an Existing Repository
          2. Creating a Repository with Xcode Server
          3. Adding a Reference to a Repository
          4. Setting Up a “Remote”—Locally
          5. Pushing to the Remote
        5. Merges and Conflicts
          1. User A
          2. User B
          3. Back to User A
        6. The Version Editor
          1. Comparison
          2. Blame
          3. Log
        7. Branching
        8. Summary
    11. Part II: The Life Cycle of an iOS Application
      1. 8. Starting an iOS Application
        1. Planning the App
          1. Model-View-Controller
          2. The Model
          3. The Views
          4. The Controllers
        2. Starting a New iOS Project
          1. Target Editor
        3. What’s in the Project
        4. One More Thing
        5. Summary
      2. 9. An iOS Application: Model
        1. Implementing the Model
          1. Entities
          2. Attributes
          3. Relationships
        2. Managed-Object Classes
          1. Creating the Classes—the Wrong Way
          2. Why Doing It Xcode’s Way Is a Mistake
          3. The Right Way—mogenerator
          4. Extending the Classes
          5. Some Test Data
          6. Source Control and Product Files
        3. Making the Model Easier to Debug
        4. Summary
      3. 10. An iOS Application: Controller
        1. Renaming Symbols
          1. Refactoring a Method Name
          2. Refactoring a Class Name
        2. Editing the View Controller
          1. The Table View
          2. Setting Up the Passer List
          3. Creating a New Passer
        3. Live Issues and Fix-it
        4. The Real Passer Rating
          1. Another Bug
          2. Running Passer Rating
        5. Summary
      4. 11. Building a New View
        1. The Next View Controller
          1. If You Want to Add a View Controller
          2. Storyboards, Scenes, and Segues
        2. Building a View
          1. Outlets and Assistants, in Passing
          2. The Billboard View
          3. Autolayout for the Nonce
          4. Lots of Labels
        3. The Table View
        4. Outlets
          1. Hooking Up the Outlets
          2. Checking Connections
          3. Connecting PRGameListController
          4. Code Completion and Snippets
        5. Testing the Billboard View
        6. Summary
      5. 12. Autolayout in a New View
        1. Why Autolayout?
          1. Limitations of Autosizing
          2. Autolayout
          3. The Thing to Remember
        2. The Player Billboard, Revisited
          1. Why You Should Do More
          2. Constraints for Real
        3. The Label System
        4. Summary
      6. 13. Adding Table Cells
        1. The Game Table
          1. Outlets in the Table View
          2. Adding Required Protocol Methods
          3. Adding Model-to-View Support
          4. A Prototype Cell
        2. The Game Table: First Run
        3. A Custom Table Cell
        4. Adding Some Graphics
          1. A Cell with an Image in It
          2. Hooking the Image View to the Images
          3. The Assets Catalog
          4. Adding Images to the Assets Catalog
          5. Icons and Launch Images
        5. Summary
      7. 14. Adding an Editor
        1. The Plan
        2. Adding a Modal Scene
          1. An Embedded View Controller
          2. Linking the Editor to the Passer List
          3. Static Table Cells
        3. The Editor View Controllers
          1. The Editor Table
          2. Passing the Data to the Editor
          3. Getting the Data Back
        4. Segues
        5. Summary
      8. 15. Unit Testing
        1. The Test Navigator
        2. Testing the CSV Reader
          1. The CSV Test Code
          2. Test Data
          3. Running the Tests
        3. Testing and the Debugger
        4. Application Tests
        5. TestKit Assertions
          1. Simple Tests
          2. Equality
          3. Exceptions
        6. Summary
      9. 16. Measurement and Analysis
        1. Speed
          1. The Debug Navigator
          2. Instruments
          3. Optimization: First Try
          4. Optimization: Second Try
          5. Optimization: Third Try
        2. Memory
          1. Allocations: First Look
          2. Focusing on One Object Type
          3. Cleaning Up the Transients
        3. Summary
      10. 17. Provisioning
        1. Apple Developer Programs
          1. Organizations
          2. Individuals
          3. The Enterprise Program
        2. Provisioning for iOS
          1. What You’ll See
          2. Registering Your App
          3. Protecting Your Assets
          4. Submitting an iOS Application
        3. The Capabilities Editor
          1. Capabilities for Both iOS and OS X
          2. iOS Capabilities
          3. OS X Capabilities
        4. OS X Sandboxing
          1. Why Sandbox?
          2. Why Not Sandbox?
        5. Gatekeeper and Developer ID
          1. Getting a Developer ID
          2. Using Developer ID
          3. Limitations
        6. Distribution Builds
          1. Basic Build Settings
          2. Adjusting the Build Settings
          3. The Build
        7. Summary
    12. Part III: Xcode for Mac OS X
      1. 18. Starting an OS X Application
        1. The Goal
        2. Getting Started
        3. Model
          1. Porting from iOS
          2. Adding an Entity
        4. Wiring a Menu
          1. Target/Action
          2. First Responder
          3. Loading Data into MPRDocument
        5. Summary
      2. 19. Bindings: Wiring an OS X Application
        1. Laying Out the Document Window
          1. A Table View
          2. Autoresizing
        2. Filling the Table—Bindings
          1. Object Controllers
          2. Binding the Team Table
          3. Running Bindings
        3. Layering NSControllers
          1. The Passer and Game Array Controllers
          2. How Object Controllers Chain
          3. Binding the Passer Table
          4. Data Formatters—Numbers
          5. Data Formatters—Strings and Dates
        4. Running a Popover with Bindings
          1. Another Excursion into Autolayout
        5. Running the Near-Final App
        6. Summary
      3. 20. A Custom View for OS X
        1. A Graphing View
        2. Back to the View Controller
          1. Using MPRPasserGraphController
        3. QuickLook in the Debugger
        4. Custom View Properties
        5. Summary
      4. 21. Localization
        1. How Localization Works
        2. Adding a Localization
          1. Base Localization
          2. Localizing for French
          3. Trying It Out
        3. Localizing MainMenu.xib
          1. Bringing a File into Localization
        4. Localizing Info.plist
        5. Strings in Code
        6. Showing Mac Passer Rating in Finder
          1. Adding the Icons
        7. Summary
      5. 22. Bundles and Packages
        1. A Simple Package: RTFD
        2. Bundles
        3. Application Bundles
        4. The Info.plist File
          1. Localizing Info.plist
        5. Info.plist Keys for Applications
          1. Keys for Both iOS and OS X
          2. Keys for OS X
          3. Keys for iOS
        6. Info.plist
        7. Summary
      6. 23. Frameworks
        1. Adding a Framework Target
          1. Populating the Framework
          2. Using the Framework
        2. Installing a Framework
          1. Running the Application Alone
          2. Where Frameworks Go
          3. Putting the Framework in the Application
        3. Building Mac Passer Rating
          1. One More Thing
        4. Debugging a Framework
          1. The Debugger and External Targets
          2. Postmortem on Postmortem Debugging
        5. Summary
      7. 24. Property Lists
        1. Property List Data Types
        2. Editing Property Lists
          1. The Property List Editor
          2. Why Not the Property List Editor?
        3. Other Formats
          1. Text Property Lists
          2. Binary Property Lists
        4. Specialized Property Lists
        5. Summary
    13. Part IV: Xcode Tasks
      1. 25. Documentation in Xcode
        1. Quick Help
          1. Inspector
          2. Popover
        2. Open Quickly
        3. Help
        4. The Documentation Window
          1. The Navigator Sidebar
          2. The Table of Contents Sidebar
          3. Class Info
          4. Searching and Navigation
        5. Keeping Current
        6. Your Own Quick Help
          1. How to Generate Quick Help
          2. Documentation Comment Syntax
        7. Your Own Docsets
          1. Preparation
          2. Configuring Doxygen: Basic Settings
          3. Configuring Doxygen: Expert Settings
          4. Running Doxygen
          5. Installing a Docset
        8. Summary
      2. 26. The Xcode Build System
        1. How Xcode Structures a Build
        2. Build Variables
        3. Settings Hierarchy
          1. Levels
        4. Editing Build Variables
        5. Configurations
          1. Adjusting Configurations
        6. Configuration Files
          1. Creating a Configuration File
          2. SDK- and Architecture-Specific Settings
          3. Preprocessing xcconfig Files
        7. Command-Line Tools
          1. xcodebuild
          2. xcode-select
          3. xcrun
        8. Custom Build Rules
        9. The Build Log
        10. A Simple Build Transcript
        11. Summary
      3. 27. Instruments
        1. What Instruments Is
        2. Running Instruments
          1. The Trace Document Window
          2. The Library
          3. Instrument Configuration
          4. Recording
          5. Saving and Reopening
        3. The Instruments
          1. Behavior
          2. Core Data
          3. Dispatch
          4. Filesystem
          5. Garbage Collection
          6. Graphics
          7. Input/Output
          8. Master Track
          9. Memory
          10. System
          11. System—iOS Energy Instruments
          12. Threads/Locks
          13. Trace
          14. UI Automation
          15. User Interface
        4. Custom Instruments
        5. The Templates
          1. All Platforms
          2. iOS Only
          3. Mac Only
        6. Summary
      4. 28. Debugging
        1. Scheme Options
          1. Info
          2. Arguments
          3. Options
          4. Diagnostics
        2. Doing More with Breakpoints
        3. The lldb Command Line
        4. Tips
        5. Summary
      5. 29. Continuous Integration
        1. Xcode Server
          1. Repositories
          2. Settings
          3. Turn It On
        2. Bots
          1. Creating a Bot in Xcode
          2. Create a Bot on the Web
          3. Running a Bot
        3. Seeing the Results
        4. Building for Distribution
        5. Summary
      6. 30. Snippets
        1. Tricks
          1. General
          2. Code-Folding Ribbon
          3. The Assistant Editor
          4. Instruments and Debugging
          5. Building
          6. Workspaces
        2. Traps
    14. Part V: Appendixes
      1. A. Some Build Variables
        1. Useful Build Variables
        2. Environment
        3. Code Signing
        4. Locations
          1. Source Locations
          2. Destination Locations
          3. Bundle Locations
        5. Compiler Settings
        6. Search Paths
        7. Info.plist
        8. The DEVELOPER Variables
        9. Source Trees
      2. B. Resources
        1. Books
        2. On the Net
          1. Forums
          2. Mailing Lists
          3. Developer Technical Support
          4. Sites and Blogs
        3. Face to Face
          1. Meetings
          2. Classes
        4. Other Software
          1. Text Editors
          2. Helpers
          3. Package Managers
          4. Version Control
          5. AppCode
          6. Alternatives to Cocoa
          7. Alternatives to Objective-C
    15. Index

    Product information

    • Title: Xcode 5 Start to Finish: iOS and OS X Development
    • Author(s): Fritz Anderson
    • Release date: May 2014
    • Publisher(s): Addison-Wesley Professional
    • ISBN: 9780133751031