Book Image

Building Apple Watch Projects

By : Stuart Grimshaw
Book Image

Building Apple Watch Projects

By: Stuart Grimshaw

Overview of this book

With Apple’s eagerly anticipated entry into the wearable arena, the field is wide open for a new era of app development. The Apple Watch is one of the most important technologies of our time. This easy-to-understand book takes beginners on a delightful journey of discovering the features available to the developer, right up to the completion of medium-level projects ready for App Store submission. It provides the fastest way to develop real-world apps for the Apple Watch by teaching you the concepts of Watch UI, visual haptic and audio, message and data exchange between watch and phone, Web communication, and finally Visual, haptic as well as audio feedback for users. By the end of this book, you will have developed at least four fully functioning apps for deployment on watchOS 2.
Table of Contents (17 chapters)
Building Apple Watch Projects
About the Author
About the Reviewer


Building Apple Watch Projects provides you with end-to-end guidance on creating a range of apps for the Apple Watch, covering such essential topics as location frameworks, data storage, communication with the iPhone, and animation, to name just a few. It applies the reader's basic Swift knowledge to real-world programming challenges in an easy, step-by-step manner, starting with a simple animated version of the ubiquitous Hello World app, progressing to apps that are Internet connected, location-aware, and fascinating to use, spanning the genres of productivity, games, and lifestyle apps.

The book contains many tips around making the best use of your coding skills, the tools that surround app development, and the many resources and utilities that exist to make your progress as a developer as smooth and enjoyable as it can be.

By the end of this book, you will have taken apps from the earliest conceptual stages right up to the Store submission.

What this book covers

Chapter 1, Exploring the New Platform, introduces the reader to the Apple Watch itself and the many design features that set the context in which the rest of the book is presented.

Chapter 2, Hello Watch, covers the setup of a new Xcode project and the creation of an uncomplicated but attractive take on the Hello World theme, including a little animation eye candy.

Chapter 3, C-Quence – A Memory Game, presents a minimalist version of a common memory game and covers the planning and design of an app that will involve more than one screen.

Chapter 4, Expanding on C-Quence, builds on the preparations of Chapter 3 to complete a colorful and functional working app, which will also be able to communicate with its paired iPhone to gather textual input from the user.

Chapter 5, On Q – A Productivity App, makes use of image assets to add a little sophistication to the user interface of a cue-card app, introduces an interactive menu screen, and makes use of the Taptic Engine to provide feedback to the user.

Chapter 6, Watching the Weather, adds Internet connectivity into the mix to create a weather app that fetches its live data from the Web and presents it using a table-based interface. This chapter also introduces the Glance screen, making a portion of the data available to the user without launching the app.

Chapter 7, Plot Buddy – All about Location, presents a location-aware app, with which the user can store sets of location data, with or without its paired iPhone. We also see the introduction of Swift protocols and custom initialization methods.

Chapter 8, Images, Animation, and Sound, adds icons to the app as well as introducing sequential animations and audio/video media playback. We also look at configuring an app's UI almost purely in code, in addition to class extensions and Xcode asset catalogs.

Chapter 9, Wear It, Test It, Tweak It, Ship It, is all about the steps to be taken after coding is finished, including installation and testing on a physical device as well as preparation of everything that is necessary for submission to the App Store.

Chapter 10, This Is Only the Beginning, takes a look at some more advanced techniques to make your apps stand out from the crowd, introduces some techniques for improving your workflow, and covers a range of topics that any watchOS/iOS developer will want to add to his or her programming skills, including a number of peripheral tools essential to professional work in a team environment, in order to set the stage for the reader's progress beyond the ground covered by this book.

What you need for this book

To create and build the code presented here, you will need nothing more than Apple's Xcode software package, which you can download for free in the App Store, and a Mac to run it on. A number of other tools are introduced, such as the OS X Terminal app, which are already installed on your Mac.

Testing the code can be done using Xcode's Simulator app, though the reader is encouraged to run the apps on a physical device, which is important when testing production-ready code (and is much more fun).

Who this book is for

If you have some basic knowledge of programming in Swift and are looking for the best way to get started with Apple Watch development, this book is just the right one for you!


In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, dummy URLs, and user input are shown as follows:

"We can include other contexts through the use of the include directive."

A block of code is set as follows:

var sequence: [Color] = []
var nextAnswerIndex: Int = 0

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

func clearGame() {
    sequence = []
    nextAnswerIndex = 0

Any command-line input or output is written as follows:

# cp /usr/src/asterisk-addons/configs/cdr_mysql.conf.sample

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "You will be presented with the Play button."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from


Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.


You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.