Learning Xcode 8

Book description

Learn how to use the power of Xcode to turn your next great app idea into a reality

About This Book

  • Learn the theory and tools behind app development using Swift 3 and Xcode 8
  • Build a fully featured iOS app, including a companion app for the Apple Watch
  • Optimize, debug, and ultimately release your app on Test Flight and the App Store

Who This Book Is For

This book is intended for programmers looking to get a jump-start into the world of iOS development. Whether you're a young student who has only spent a few months with Java, or a seasoned developer who has spent their career developing for a different platform, all that is expected is a basic understanding of a programming language such as C++, C#, or Java.

What You Will Learn

  • Understand the most important features of the Xcode IDE
  • Write Swift 3 code for application data models and view controllers
  • Prepare visual layouts for an iOS application using storyboards, size classes, and auto-layout
  • Integrate many common technologies into an app, such as multi-touch gestures, CoreData, and notifications
  • Build companion applications for the Apple Watch with watchOS 3
  • Debug applications using Xcode's suite of debugging tools, and prevent bugs with unit testing
  • Optimize an application using Xcode 8's profiling tools and asset catalogs
  • Distribute a beta application through TestFlight, and a finished application through the App Store

In Detail

Over the last few years, we've seen a breakthrough in mobile computing and the birth of world-changing mobile apps. With a reputation as one of the most user-centric and developer-friendly platforms, iOS is the best place to launch your next great app idea. As the official tool to create iOS applications, Xcode is chock full of features aimed at making a developer's job easier, faster, and more fun.

This book will take you from complete novice to a published app developer, and covers every step in between. You'll learn the basics of iOS application development by taking a guided tour through the Xcode software and Swift programming language, before putting that knowledge to use by building your first app called ?Snippets.? Over the course of the book, you will continue to explore the many facets of iOS development in Xcode by adding new features to your app, integrating gestures and sensors, and even creating an Apple Watch companion app. You'll also learn how to use the debugging tools, write unit tests, and optimize and distribute your app. By the time you make it to the end of this book, you will have successfully built and published your first iOS application.

Style and approach

This easy-to-follow guide presents topics in a hands-on lecture format where concepts are introduced and explained, then used in an example as reinforcement. The first third of the book covers the separate building blocks of development, while the second two thirds cover the development of an app from start to finish.

Table of contents

  1. Learning Xcode 8
    1. Table of Contents
    2. Learning Xcode 8
    3. Credits
    4. About the Author
    5. About the Reviewer
    6. www.PacktPub.com
      1. eBooks, discount offers, and more
        1. Why subscribe?
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    8. 1. Starting Your iOS Journey
      1. A developer's responsibilities
        1. Pre-production
        2. Project setup
        3. Development
        4. Deployment
      2. Working on a team
        1. Designers
        2. Other programmers
        3. Project managers
        4. Investors
      3. The Xcode 8 toolset
        1. Xcode
        2. iOS and watchOS simulator
        3. Instruments
        4. Application Loader
      4. Understanding Model-View-Controller (MVC)
        1. Model
        2. View
        3. Controller
        4. MVC on the web
        5. MVC on iOS
      5. Becoming a registered developer
        1. Which account do you need?
        2. Registering a free developer account
        3. Registering a paid developer account
      6. Summary
    9. 2. Welcome to Xcode
      1. Getting started
        1. Installing Xcode
        2. Adding your developer account
        3. Creating a new project
      2. Navigating Xcode
        1. Editor
        2. Navigator sidebar
        3. Debug area
        4. Utilities sidebar
      3. Exploring the editor
        1. Standard editor
        2. Assistant editor
        3. Version editor
      4. Understanding project settings
        1. Project targets
        2. The General tab
        3. The Capabilities tab
        4. The Info tab
      5. Creating and managing files
        1. Resource types
        2. Creating new resources
        3. Importing existing files
        4. Groups and folders
      6. Creating builds
        1. Build and run
        2. Running on a device
      7. Applying the basics
        1. Setting up the workspace
        2. Creating the model, view, and controller
        3. Testing our work in the simulator
      8. Summary
    10. 3. Introduction to Swift 3
      1. Discovering playgrounds
        1. Setting up a playground
          1. Using previews
        2. Resources, pages, and rich comments
          1. Resources
          2. Pages
          3. Rich comments
      2. Understanding Swift basics
        1. Data types, constants, and variables
          1. Data types
          2. Constants
          3. Variables
        2. Optionals
        3. Collection types
          1. Arrays
          2. Dictionaries
        4. Conditional statements
          1. if statement
          2. guard statement
          3. switch statement
        5. Loops
          1. for loop
          2. for-in loop
          3. while loop
          4. repeat-while loop
        6. Functions
        7. Comments and printing
      3. Creating classes, structs, and enums
        1. Classes
        2. Structs
        3. Enumerations
      4. Using important Swift features
        1. Closures
        2. Protocols
        3. Class extensions
        4. Error handling
      5. Summary
    11. 4. Using Storyboards, Auto Layout, and Size Classes
      1. Storyboards
        1. Getting started
        2. View controllers and screen flow
        3. Understanding segues
      2. Auto Layout
        1. The view hierarchy
          1. Constraints
          2. Resolving issues
      3. Size classes
        1. Devices, orientations, and size classes
        2. Size classes in action
      4. Summary
    12. 5. Taking Advantage of Source Control in Xcode
      1. Understanding version control
      2. Introduction to Git
      3. Setting up Git in Xcode
        1. Creating a local repository
        2. Adding Git to an existing project
        3. Using a GitHub hosted repository
      4. Using version control in Xcode
        1. Pull, push, and commit
        2. The version editor
        3. Creating and merging branches
      5. Summary
    13. 6. Building Your First iOS App
      1. Pre-production
        1. Assembling a feature list
        2. Visual design
        3. Creating a development plan
      2. New snippet
        1. SnippetData model
        2. New snippet button
      3. Select snippet type
        1. Update SnippetData model
        2. Create an alert controller
      4. Text snippet implementation
        1. Update SnippetData model
        2. Text entry view controller
      5. PhotoSnippet implementation
        1. Update SnippetData model
        2. PhotoSnippet data entry
      6. Scroll through snippets
        1. Create prototype cells
        2. Populate table view
      7. Snippet dates
        1. Update SnippetData model
        2. Save data to model
        3. Update view and controller
      8. Summary
    14. 7. Integrating Multitouch and Gestures
      1. Human interface guidelines – gestures
        1. Standard gestures
        2. Usage guidelines
        3. How gestures work
      2. Adding gestures from the storyboard
        1. Setting up the storyboard
        2. Flipping the image
      3. Adding gestures from code
        1. Creating a gesture through code
        2. Reading the gesture data
        3. Changing the scale of our image
        4. If you're up for a challenge…
      4. Creating 3D Touch app shortcuts
        1. Setting up Info.plist
        2. Handling shortcuts in the app delegate
      5. Summary
    15. 8. Exploring Common iOS Frameworks
      1. Frameworks
        1. What is a framework?
        2. Linking frameworks in a project
      2. Understanding UIKit fundamentals
        1. Application management
          1. The UIDevice class
        2. Views
          1. Drawing
          2. Hierarchies
          3. Coordinate systems
        3. Documents, displays, printing, and more
          1. Documents
          2. Displays
          3. Printing
          4. And more!
      3. Using CoreLocation.framework
        1. Setting up CoreLocation permissions
        2. Getting the user's location
        3. Adding location data to Snippets
      4. Using Social.framework
        1. Setting up the views
        2. Posting to Twitter
      5. Summary
    16. 9. Working with Core Data
      1. What is Core Data?
        1. Model revisited
        2. Entities, attributes, and relationships
          1. Entities
          2. Attributes
          3. Relationships
        3. The data model editor
      2. Preparing Snippets for Core Data
        1. Initializing the Core Data stack
          1. Data model versus object graph
          2. The NSManagedObjectModel
          3. The NSPersistentStoreCoordinator
          4. The NSManagedObjectContext
          5. Final touches
        2. Recreating the data model with Core Data
      3. Persisting data
        1. Saving data
        2. Fetching data
        3. Deleting data
      4. Summary
    17. 10. Creating a watchOS Companion App
      1. Designing for the Apple Watch
        1. Using the watch
        2. Intended experience
        3. Apple's design principles
      2. Components of a watchOS app
        1. The watchOS app
          1. Dock snapshots
          2. Notifications
            1. Complications
      3. Architecture of a watchOS app
        1. Target bundles
          1. Watch App bundle
          2. Watch Extension bundle
        2. Interface controller
        3. Extension Delegate
      4. Snippets for Apple Watch
        1. Setting up our project
          1. Creating a watchOS storyboard
          2. Programming the interface controller
          3. Connecting to iOS with Watch Connectivity.framework
          4. Adding a complication
      5. Summary
    18. 11. Advanced Input Using Sensors
      1. Device status with UIDevice
        1. Accessing orientation state
        2. Checking the proximity sensor
        3. Getting battery status
      2. Introduction to Core Motion
        1. Accelerometer
      3. Gyroscope
      4. CMDeviceMotion
        1. User acceleration
        2. Gravity
        3. Rotation rate
        4. Magnetic field
          1. Charting motion data
        5. Charts
          1. Importing the framework
          2. Setting up the storyboard
          3. Filling the chart with data
        6. Pedometer
        7. Altitude
      5. Sensors on Apple Watch
        1. Setting up an extension
        2. Getting sensor data on Apple Watch
        3. Sending and displaying data on iOS
      6. Summary
    19. 12. Sending Notifications
      1. Introduction to user notifications
        1. Components of a user notification
        2. Local versus remote notifications
      2. Adding notification support to Snippets
        1. Getting permission to send notifications
        2. Scheduling a local notification
      3. Advanced notifications
        1. Categories and actions
        2. Badges
        3. Custom sounds
        4. Receiving notifications while in the app
      4. Summary
    20. 13. Writing Unit Tests
      1. Introduction to unit tests
        1. What is a unit?
        2. Why use unit testing in the first place?
      2. Unit tests in action
        1. Setting up the project
        2. Writing tests with XCTest
        3. Running tests
      3. Implementing tests for Snippets
        1. Setting up the Snippets project
        2. Preparing our testing class
        3. Writing a data validation unit test
        4. Checking code coverage
      4. Testing UI in Xcode 8
        1. How does UI testing work?
        2. Adding the UI testing target
        3. Using the UI recorder
      5. Summary
    21. 14. Debugging an iOS Application
      1. Basic debugging practices
        1. print()
        2. Breakpoints and the debug area
          1. Variables view
          2. Console
          3. Debug toolbar
        3. The call stack
      2. Advanced debugging tools
        1. Address Sanitizer
        2. Performance gauges
          1. CPU and memory gauge
          2. Disk and network gauge
          3. Energy gauge
      3. Visual debugging
      4. Summary
    22. 15. Optimizing Your App
      1. Introduction to Instruments
        1. Time Profiler instrument
          1. Anatomy of an Instruments document
          2. Using the Time Profiler
        2. Allocations instrument
        3. Leaks instrument
        4. App Thinning
        5. Slicing
        6. Bitcode
        7. On-demand Resources
          1. Creating tags
          2. Loading resources
          3. Purging resources
      2. Summary
    23. 16. Distributing an iOS App
      1. Preparing iTunes Connect
        1. Registering a bundle identifier
        2. Creating a new app record in iTunes Connect
      2. Uploading to iTunes Connect
      3. Releasing the app
        1. Finalizing store assets
        2. Distributing on TestFlight
        3. Submitting to the App Store
      4. Summary
    24. Index

Product information

  • Title: Learning Xcode 8
  • Author(s): Jak Tiano
  • Release date: November 2016
  • Publisher(s): Packt Publishing
  • ISBN: 9781785885723