You are previewing Xcode 6 Start to Finish: iOS and OS X Development, Second Edition.
O'Reilly logo
Xcode 6 Start to Finish: iOS and OS X Development, Second Edition

Book Description

Use Xcode 6 to Craft Outstanding iOS and OS X Apps!

Xcode 6 Start to Finish will help you use Apple’s Xcode 6 tools to improve productivity, write great code, and leverage the newest iOS 8 and OS X Yosemite features, including Apple’s new Swift programming language.

Drawing on more than thirty years of experience developing for Apple platforms, and helping others do so, Fritz Anderson presents a complete best-practice workflow that reflects Xcode’s latest innovations. Through three full, sample projects, you’ll learn to integrate testing, source control, and other key skills into a high-efficiency process that works. And all sample code has been completely written in Swift, with figures and descriptions that reflect Xcode’s radically new interface.

This is the only Xcode 6 book focused on deep mastery of the tools you’ll be living with every day. Anderson reveals better ways to storyboard, instrument, build, and compile code, and helps you apply new features, ranging from Interface Builder Live Rendering to View Debugging and XCTest Performance Testing. By the time you’re finished, you’ll have all the Xcode 6 skills you need in order to develop truly exceptional software.

Coverage includes

  • Working with iOS-side dynamic frameworks and iOS/OS X extension modules

  • Streamlining Model, View, and Controller development with Swift

  • Rewriting Objective-C functions in Swift

  • Efficiently managing layouts and view hierarchies with size classes

  • Inspecting and fixing interface issues with the new View Debugger

  • Displaying and configuring custom views within Interface Builder via Live Rendering

  • Benchmarking performance within the Xcode 6 unit test framework

  • Leveraging Xcode 6 automated tools to simplify localization

  • Creating new extensions to inject services and UI into other applications

  • Mastering new Swift debugging techniques

  • Register your book at 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. Dynamic Loading
        3. Xcode and Clang
          1. Local Analysis
          2. Cross-Function Analysis
          3. Indexing
        4. Swift
        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. Setting Up a “Remote”—Locally
          2. 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. 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
        3. Preparation
          1. Utilities
          2. Extensions
          3. passer rating
        4. Specializing the Core Data Classes
          1. Putting Game to Work
          2. Putting Passer to Work
          3. Some Test Data
          4. Source Control and Product Files
        5. Making the Model Easier to Debug
        6. Summary
      3. 10. An iOS Application: Controller
        1. Renaming Symbols in Objective-C
          1. Refactoring the Name of an Objective-C Method
          2. Refactoring a Class Name
        2. Renaming a Class in Swift
        3. Editing the View Controller
          1. The Table View
          2. Setting Up the Passer List
          3. Creating a New Passer
        4. Live Issues and Fix-it
        5. The Real Passer Rating
          1. Another Bug
          2. Running Passer Rating
        6. 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. Linking Views to a View Controller
          4. Auto Layout for the Nonce
          5. Lots of Labels
          6. Cleaning Up
        3. The Table View
        4. Outlets
          1. Hooking Up the Outlets
          2. Checking Connections
          3. Connecting GameListController
          4. Code Completion and Snippets
          5. Code Snippets
        5. Testing the Billboard View
        6. Summary
      5. 12. Auto Layout in a New View
        1. Why Auto Layout?
          1. Limitations of Autoresizing
          2. Auto Layout
          3. The Thing to Remember
        2. The Player Billboard, Revisited
          1. Why You Should Do More
        3. Factoring Layout into Subviews
          1. The Playground
          2. StatView
          3. Installing StatView
        4. Planning Constraints
        5. Two Line Counts, Two Labels
        6. Constraints for Real
          1. Default (Any/Any)
          2. Any Height (not Compact)
          3. Landscape (wAny/hCompact)
          4. Chasing Issues
          5. A Tweak
        7. 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 Displays
        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. Adding a Test Class
        5. Asynchronous Tests
          1. Testing Asynchronous Code
          2. Documentation of Last Resort
        6. XCTest Assertions
          1. Simple Tests
          2. Equality
          3. Exceptions
        7. Summary
      9. 16. Measurement and Analysis
        1. Speed
          1. The Debug Navigator
          2. Instruments
        2. XCTest and Performance
        3. Memory
        4. Summary
      10. 17. An iOS Extension
        1. Adding the Today Target
        2. Designing the Widget
          1. Data Access
        3. A Shared Library in a Framework
        4. The Today Extension
        5. Build Dependencies
        6. The Result
        7. Summary
      11. 18. Provisioning
        1. Apple Developer Programs
          1. General (App Store) Program
          2. Enterprise Program
        2. Provisioning for iOS
          1. What You’ll See
          2. Registering Your App
          3. Protecting Your Assets
          4. Prerelease Distributions
        3. The Capabilities Editor
          1. OS X-only Capability
          2. Capabilities for Both iOS and OS X
          3. iOS 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. 19. 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 LeagueDocument
          4. Adapting to a Managed Document
          5. Testing the Command
          6. Identifying a Type for League Data
          7. Specifying How the App Handles League Files
          8. Application and Document Icons
        5. Summary
      2. 20. Bindings: Wiring an OS X Application
        1. Storyboard Segues in OS X
        2. Building the Document Window
          1. Loading the Window
          2. A Table View
        3. Filling the Table—Bindings
          1. Object Controllers
          2. Binding the Table to the Teams
          3. Binding the Columns to Team Properties
        4. The Arc of League Document Data
          1. From League Table to Source List
          2. Capturing the Team Selection
          3. From Team to Tables
          4. The Passer Section
        5. Summary
      3. 21. Localization
        1. How Localization Works
        2. Adding a Localization
          1. Base Localization
          2. Why Base Localization?
        3. Something Worth Localizing
          1. Game Detail View: Layout
          2. Game Detail View: Code
          3. Modules and Namespaces
        4. Localizing for French
          1. Adding a Locale
          2. Starting Simple: Credits.rtf
          3. Localizing Main.storyboard
          4. Localizing Resources
          5. Localizing Program Strings
          6. genstrings
          7. xliff Files
          8. The Rest
        5. Localizing System Strings
        6. Summary
      4. 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. Summary
      5. 23. 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
          3. JSON
        4. Specialized Property Lists
        5. Summary
    13. Part IV: Xcode Tasks
      1. 24. 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. C-Family Documentation
          2. Doxygen
          3. Running Doxygen
          4. Installing a Docset
        7. Swift and reStructuredText
        8. Summary
      2. 25. 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. Builds in the Report Navigator
        10. A Simple Build Transcript
        11. Summary
      3. 26. Instruments
        1. What Instruments Is
        2. Running Instruments
        3. The Trace Document Window
          1. Toolbar
          2. Track Area
          3. Detail Area
          4. Extended Detail Area
          5. Library
        4. Tracing
          1. Recording
          2. Saving and Reopening
          3. Tracing without Instruments
        5. The Instruments
          1. Behavior
          2. Core Data
          3. Dispatch
          4. Filesystem
          5. Graphics
          6. Input/Output
          7. Master Tracks
          8. Memory
          9. System
          10. System—iOS Energy Instruments
          11. Threads/Locks
          12. Trace
          13. UI Automation
          14. User Interface
        6. Custom Instruments
        7. The Templates
          1. All Platforms
          2. iOS Only
          3. Mac Only
        8. Summary
      4. 27. Debugging
        1. Scheme Options
          1. Info
          2. Arguments
          3. Options
          4. Diagnostics
        2. Doing More with Breakpoints
        3. View Hierarchy
        4. The lldb Command Line
        5. Tips
        6. Summary
      5. 28. Snippets
        1. Tricks
          1. General
          2. Code-Folding Ribbon
          3. The Assistant Editor
          4. Instruments and Debugging
          5. Building
        2. Traps
    14. Part V: Appendixes
      1. A. Some Build Variables
        1. Useful Build Variables
          1. Environment
          2. Code Signing
          3. Locations
          4. Compiler Settings
          5. Other Tools
          6. Info.plist
          7. Search Paths
          8. The DEVELOPER_ Variables
        2. Source Trees
      2. B. Resources
        1. Books
        2. Books about Swift
        3. On the Net
          1. Forums
          2. Mailing Lists
          3. Developer Technical Support
          4. Sites and Blogs
        4. Face to Face
          1. Meetings
          2. Classes
        5. Other Software
          1. Text Editors
          2. Helpers
          3. Package Managers
          4. Version Control
          5. AppCode
          6. Alternatives to Cocoa
    15. Index
    16. Code Snippets