Preface

Apple has given developers a lot of toys to play with, and a lot of new things to learn over the past few years: iPhone, iPad, Swift, and now the Apple Watch. We’ve been using Swift to build OS X and iOS apps for nearly a year (and enjoying every moment of it), but now we can also use it to build apps for a tiny wrist-mounted computer—the kind of science-fiction gadget that we used to dream about as kids is now reality! We can’t wait to see the apps people create for the Apple Watch.

This book introduces the basic components available to developers who want to build apps for the Apple Watch. If you’re already familiar with Swift, this book has all the basics you need to get familiar with the fundamentals of Apple Watch development. If you’re in the middle of learning Swift from another book or video series, this book provides an excellent resource to move to once you’re familiar with Swift and ready to tackle the Apple Watch.

We hope you enjoy learning the basics of Apple Watch development with this book!

Audience

This book assumes that you already know how to use Swift. If you’ve worked through any other Swift-based book available from O’Reilly, like Learning Swift, you should be good to go with this book.

We assume that you’re a relatively capable programmer who is happy and confident navigating around OS X, Xcode, and iOS, but we don’t assume you know how to program for the Apple Watch (that’s what this book is for!)

Organization of This Book

In this book, we’ll be discussing the basics of using Apple’s WatchKit framework to build watchOS apps. We’ll be coding in Swift, Apple’s newest programming language.

Here is a concise breakdown of the material each chapter covers:

Chapter 1 reviews what the Apple Watch is—and what it isn’t. We discuss how and why people might interact with your Apple Watch app, the life cycle of an app, and how it interacts with the user’s iPhone. We also briefly touch on design contraints and UI controls available for use in your Apple Watch apps.

Chapter 2 teaches you how to build an Apple Watch app and its iOS counterpart. We talk about adding controls, working with multiple screens in your app, and sharing data with iOS apps.

Chapter 3 discusses glances, the non-interactive component of Apple Watch apps that provides glanceable information to users. We will also demonstrate how to build a simple glance.

Chapter 4 covers notifications and the Apple Watch. We discuss creating, presenting, and customizing notifications, as well as how to test notifications and connect them to your interface controller(s).

Chapter 5 discusses complications, which let you embed small information displays directly into the watch face to provide timely information to the user.

Conventions Used in This Book

The following typographical conventions are used in this book:

Italic

Indicates new terms, URLs, email addresses, filenames, and file extensions.

Constant width

Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.

Constant width bold

Shows commands or other text that should be typed literally by the user.

Constant width italic

Shows text that should be replaced with user-supplied values or by values determined by context.

Tip

This element signifies a tip or suggestion.

Note

This element signifies a general note.

Warning

This element indicates a warning or caution.

Using Code Examples

Supplemental material (code examples, exercises, errata, etc.) is available for download at our site.

This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Swift Development for the Apple Watch by Jon Manning and Paris Buttfield-Addison (O’Reilly). Copyright 2016 Secret Lab, 978-1-491-92520-1.”

If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at .

Finally, we’d be remiss if we didn’t link to our own blog.

Safari® Books Online

Note

Safari Books Online is an on-demand digital library that delivers expert content in both book and video form from the world’s leading authors in technology and business.

Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.

Safari Books Online offers a range of plans and pricing for enterprise, government, education, and individuals.

Members have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and hundreds more. For more information about Safari Books Online, please visit us online.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

  • O’Reilly Media, Inc.
  • 1005 Gravenstein Highway North
  • Sebastopol, CA 95472
  • 800-998-9938 (in the United States or Canada)
  • 707-829-0515 (international or local)
  • 707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at http://bit.ly/swift-dev-apple-watch.

To comment or ask technical questions about this book, send email to .

For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.

Find us on Facebook: http://facebook.com/oreilly

Follow us on Twitter: http://twitter.com/oreillymedia

Watch us on YouTube: http://www.youtube.com/oreillymedia

Acknowledgments

Jon thanks his mother, father, and the rest of his weirdly extended family for their tremendous support.

Paris thanks his mother, whose credit card bankrolled literally hundreds of mobile devices throughout his childhood—an addiction that, in all likelihood, created the gadget-obsessed monster he is today. He can’t wait to read her upcoming novel.

Thank you to our editor, Rachel Roumeliotis, who kept the book under control and provided a ton of useful advice on content (we know it was a ton because we measured it). Likewise, all the O’Reilly Media staff and contractors we’ve worked with over the course of writing the book have been absolutely fantastic, and their collective efforts have made this book better. Thank you also to Brian Jepson, our first editor at O’Reilly.

A huge thank you to Tony Gray and the Apple University Consortium (AUC) for the monumental boost they gave us and many others listed on this page. We wouldn’t be working in this industry, let alone writing books, if it wasn’t for Tony and the AUC community.

Thanks also to Neal Goldstein, who richly deserves all of the credit and/or blame for getting both of us into the whole book-writing racket.

We’d like to thank the support of the goons at MacLab, who know who they are and continue to stand watch for Admiral Dolphin’s inevitable apotheosis, as well as Professor Christopher Lueg, Dr Leonie Ellis, and the rest of the staff at the University of Tasmania for putting up with us.

Additional thanks to Tim N., Nic W., Andrew B., Jess L., and Rex S. for a wide variety of reasons. Thanks also to Ash Johnson, for general support.

Finally, very special thanks to Steve Jobs, without whom this book (and many others like it) would not have reason to exist.

Get Swift Development for the Apple Watch now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.