Developing for Apple Watch, Second Edition
Create Native watchOS 2 Apps with the WatchKit SDK
by Jeff Kelley
Version: P1.0 (May 2016)
Copyright 2016 The Pragmatic Programmers, LLC. This book is licensed to the individual who purchased it. We don't copy-protect it because that would limit your ability to use it for your own purposes. Please don't break this trustyou can use this across all of your devices but please do not share this copy with other members of your team, with friends, or via file sharing services. Thanks.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC was aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking g device are trademarks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher assumes no responsibility for errors or omissions, or for damages that may result from the use of information (including program listings) contained herein.
About the Pragmatic Bookshelf
The Pragmatic Bookshelf is an agile publishing company. Were here because we want to improve the lives of developers. We do this by creating timely, practical titles, written by programmers for programmers.
Our Pragmatic courses, workshops, and other products can help you and your team create better software and have more fun. For more information, as well as the latest Pragmatic titles, please visit us at http://pragprog.com.
Our ebooks do not contain any Digital Restrictions Management, and have always been DRM-free. We pioneered the beta book concept, where you can purchase and read a book while its still being written, and provide feedback to the author to help make a better book for everyone. Free resources for all purchasers include source code downloads (if applicable), errata and discussion forums, all available on the book's home page at pragprog.com. Were here to make your life easier.
New Book Announcements
Want to keep up on our latest titles and announcements, and occasional special offers? Just create an account on pragprog.com (an email address and a password is all it takes) and select the checkbox to receive newsletters. You can also follow us on twitter as @pragprog.
About Ebook Formats
If you buy directly from pragprog.com, you get ebooks in all available formats for one price. You can synch your ebooks amongst all your devices (including iPhone/iPad, Android, laptops, etc.) via Dropbox. You get free updates for the life of the edition. And, of course, you can always come back and re-download your books when needed. Ebooks bought from the Amazon Kindle store are subject to Amazon's polices. Limitations in Amazon's file format may cause ebooks to display differently on different devices. For more information, please see our FAQ at pragprog.com/frequently-asked-questions/ebooks. To learn more about this book and access the free resources, go to https://pragprog.com/book/jkwatch2, the book's homepage.
Thanks for your continued support,
Dave Thomas and Andy Hunt
The Pragmatic Programmers
The team that produced this book includes: Rebecca Gulick (editor) Potomac Indexing, LLC (indexer) Linda Recktenwald (copyeditor) Gilson Graphics (layout) Janet Furlow (producer)
For customer support, please contact .
For international rights, please contact .
Table of Contents
Copyright 2016, The Pragmatic Bookshelf.
Early praise for Developing for Apple Watch, Second Edition
Often with a new technology, the first books are just retreads of the official docs for years until developers dig into the APIs. With Jeff Kelley having taken that step for us already by working on some of the first shipping WatchKit apps, we get a huge head start. His book is deeply rooted in hard-won lessons about what actually works on Apple Watch, and he shows how to make apps that can really shine on this new platform.
Chris Adamson |
Author of iOS 9 SDK Development and Software Engineer, Rev.com |
This is an essential book for any iOS developer interested in getting started with WatchKit. It starts you off with a detailed summary of all of the Apple Watch features and capabilities, and then progresses along a logical path to advanced concepts and performance strategies. Working through each chapter, I started to develop several potential app and app-compliment ideas. Ill be referring to this book often in the near future.
Kevin J. Garriott |
Director, Mobile Technology, Rockfish |
Apple Watch development is new and evolving territory, and this book covers all the bases. If you want to tackle watchOS development, the information you need to fire on all pistons is right here.
Kevin Munc |
Senior iOS Developer, Method Up LLC |
Get energized to develop for the Apple Watch with this book, and learn from an expert!
Mayur S Patil |
Assistant Professor, MIT Academy of Engineering, Maharashtra Academy of Engineering and Education Research, Alandi D, Pune |
This book does a clear job of going through Apple Watch development in a linear fashion. It will serve as an informative reference for any developer, due to its nicely segmented topics and excellent code examples.
Jason Humphries |
Lead iOS Engineer, WedPics |
This book tells you how to decide what to build for an Apple Watch and guides you through the whole development.
Gbor Lszl Hajba |
IT Consultant, EBCONT Enterprise Technologies GmbH |
Acknowledgments
The more books I write, the more I appreciate those around me who help me do it.
This book never would have been finished without the continued efforts of Rebecca Gulick, my editor, and the entire staff at The Pragmatic Bookshelf. Their questions, comments, and editing shaped the book into what it is today. Along the same lines, I owe a great deal of thanks to the tech reviewers who helped go over pre-release versions of the book: Chris Adamson, Thomas Alvarez, Albert Choy, Kevin Garriott, Gbor Lszl Hajba, Alexander Henry, Jason Humphries, Carlos Lopez, Kevin Munc, Stephen Orr, Mayur Patil, Kim Shrier, Mario Tatis, Mattio Valentino, Matthew White, and Stephen Wolff. Thanks to them taking time out of their busy schedules, the books technical contents are that much more accurate.
Working on a book necessarily means not doing other things, and my family has definitely had to put up with my absence and distraction as Ive undertaken writing this one. Theyve earned many thanks. Hopefully watchOS 3 wont change as much as watchOS 2 did!
Finally, Id like to thank my coworkers and the cofounders of Detroit Labs. Working at such an amazing place allows me to do things like write books in my free time. I can honestly say Detroit Labs is the best place Ive ever worked, and I cant imagine being anywhere else.
Copyright 2016, The Pragmatic Bookshelf.
Preface
Apple Watch has inspired a brand-new platform, watchOS, for iOS developersthats you!to take advantage of. Youre now competing not only for your users iPhone screens but also for space on their wrists. For the first time, you can make an iOS app that your users will actually wear . As intimate as that is, you want to make sure you can deliver the best experience possible so your app will stay on those wrists. This book will help you make an app that not only stays on your users wrists, but that they use every single time they look at their watch.