You’ve got a great idea for an Apple Watch app. But how do you get your app from idea to wrist? This book shows you how to make native watchOS apps for Apple’s most personal device yet. You’ll learn how to display beautiful interfaces to the user, how to use the watch’s heart rate monitor and other hardware features, and the best way to keep everything in sync across your users’ devices. New in this edition is coverage of native apps for watchOS 2. With the new version of the WatchKit SDK in Xcode 7, your apps run directly on the watch.
Developing for Apple Watch, Second Edition: Create Native watchOS 2 Apps with the WatchKit SDK
by Jeff Kelley
About This Title
On Apple Watch, your app is right on your users’ wrists, making your code closer than ever before. Create native watchOS apps by extending your iPhone app with a WatchKit Extension, giving your users quick access to your app’s most important features and an intimate user experience that’s always within arm’s reach.
You won’t just be creating apps—with Glances to provide timely information, notifications to inform your users of the latest updates, and watch face complications to show your users data as soon as they raise their wrists, your watchOS apps will be the best the App Store has to offer.
Any book can teach you how to make a watch app. This book will help focus your efforts and refine your app’s feature set. Which features make sense on the watch? How should you organize them? You’ll learn what to consider when judging watch app features, allowing you to come up with the best strategy for your app. You’ll test your apps on real Apple Watch hardware, and by the end of this book, you’ll be ready to ship to the App Store.
Q&A with Jeff Kelley, author of Developing for Apple Watch, Second Edition
Q: Do I need to have an Apple Watch to develop on?
A: No! Apple ships a watch simulator with Xcode, and it’s all available for free as long as you have a Mac. An Apple Watch is highly recommended for testing, but it’s not needed to go through the book.
Q: What programming language is the book in?
A: This book is in Swift, Apple’s new programming language.
Q: I know Objective-C, not Swift. Will I be able to use this book?
A: Yes! Both Objective-C and Swift code use the exact same WatchKit framework to make watch apps. The syntax is different, to be sure, but you can use Objective-C for watch apps with no problem.
Q: What will this book teach me?
A: This book covers writing watchOS apps using the WatchKit framework, creating watch face complications with the ClockKit framework, using the HealthKit framework to create health and fitness apps, and more. The focus of the book is on making watch apps.
Q: Do I need to know how to make iOS apps to read this book?
A: This book assumes that you know how to create an iOS app, but you don’t need to be an expert. As long as you’re comfortable in Xcode and understand the process of shipping an iOS app, you’ll be able to use this book. And if you’re still learning, this book will help too—aside from the watch-specific code, watchOS uses many of the same tools and frameworks as iOS.
Q: I have a great idea for a watch app, but I don’t want to make an iPhone app to go with it. Can I just put my watch app on the App Store?
A: As of iOS 9 and watchOS 2, all watch apps must be bundled inside of an iPhone app. If your app is one that only makes sense on the watch, your iPhone app can be a pretty basic shell that tells your users to install the watch app—just be sure to provide enough functionality to get approved into the App Store.
Read the reviews .
What You Need
You’ll need a Mac running OS X Yosemite capable of running Xcode 7 or later. To build your apps for your Apple Watch, you’ll need to be running watchOS 2 or later, connected to a compatible iPhone.
Contents & Extracts
- What’s in This Book?
- Who’s This Book For?
- The Code in This Book
- Online Resources
- An Overview of Apple Watch excerpt
- Apple Watch Basics
- Apple Watch App-Design Concepts
- From iPhone App to Apple Watch App
- WatchKit Extension Overview
- Creating Your First WatchKit Extension
- Adding User Interface Elements
- Adding a Glance
- The iPhone App—WatchKit Extension Relationship
- Deployment of WatchKit Apps
- WatchKit User Interfaces excerpt
- Meet WKInterfaceObject
- Creating Interface Objects
- Designing Your UI in the Storyboard
- Interface Object Layout
- Creating Your Apple Watch App
- Organizing Your UI with Groups
- Group Basics
- Adding Detail to a Screen
- Animation and Groups
- Delivering Dynamic Content with Tables excerpt
- Comparing WatchKit Tables and iOS Table Views
- Row Types and Storyboard Groups
- Linking Content to the UI with Row Controllers
- Configuring the Content in Tables
- Modifying Tables
- Considering Table Input
- Performance Concerns
- Navigating Between Interfaces
- Linking Interfaces in Your Storyboard
- Interface Transitions in Code
- Passing Data Between Interfaces
- Configuring Tracks in TapALap
- WatchKit Extension Lifecycle
- Adding Lifecycle Methods
- Adopting Handoff in the Extension Delegate
- Responding to Notifications
- Communicating with WatchConnectivity
- Making Network Requests on Apple Watch
- Preparing for WatchConnectivity: Persisting Data in TapALap
- Talking to the iPhone with WatchConnectivity
- Creating Complications with ClockKit
- Watch Faces and Complications
- Providing Complications in Your App
- Managing Complication Privacy
- Providing Placeholder Complications
- Restricting Complication Families
- Extending Complications with Time Travel
- Making Your Complication Excellent with Time Travel
- Updating Complications
- Getting Personal with Sensor Data and HealthKit
- Getting Device Motion with the CoreMotion Framework
- Working Out with HealthKit
- Unlocking Watch App Performance
- Making Apps Launch Quickly
- Increasing Performance by Removing Data
- Inspecting Performance with Instruments
- The Illusion of Performance: Preloading Data
- Being a Good Watch App Citizen
- Localizing and Internationalizing Your App
- Supporting Every User with Accessibility
Brought to You By
Jeff Kelley has been developing iOS apps since the SDK’s release in 2008. He has developed apps for major clients, and his apps have been in the top 10 list of the App Store, featured in national television campaigns, and demonstrated by corporate executives. Jeff has spoken at conferences around the United States, and when not writing, develops apps for clients in Detroit, MI.