Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Building Apple Watch Projects
Building Apple Watch Projects

Building Apple Watch Projects: Discover exciting and fun projects by building brilliant applications for the Apple Watch

Arrow left icon
Profile Icon Stuart Grimshaw
Arrow right icon
₱1799.99 ₱2000.99
eBook Feb 2016 298 pages 1st Edition
eBook
₱1799.99 ₱2000.99
Paperback
₱2500.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon Stuart Grimshaw
Arrow right icon
₱1799.99 ₱2000.99
eBook Feb 2016 298 pages 1st Edition
eBook
₱1799.99 ₱2000.99
Paperback
₱2500.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
₱1799.99 ₱2000.99
Paperback
₱2500.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Building Apple Watch Projects

Chapter 2. Hello Watch

Time to fire up the engine and get a feel for some of the new tools we have at our disposal, courtesy of Apple's Xcode development environment. Once we get started, you will recognize much of what you already know through using Xcode and Swift to build apps for iOS, whether for iPhone, iPad, or universal apps for both. The project structure will be familiar to you, and everything that you would expect to see in a purely iOS project will be present.

If you have so far been developing for OS X and not iOS, you will notice many similarities but also many differences to an OS X project. Not a problem. You know Swift already, we will be setting up the projects step by step, and we are all new to WatchKit.

Briefly, we will learn how to do the following:

  • Start and set up a project using an Xcode template
  • Create some UI elements
  • Get the app running on the Watch Simulator
  • Add some simple animation to the UI
  • Get basic input from the user

By the end of this chapter you...

Setting it all up

This will be largely familiar territory to anyone who has already created projects for iOS, with just a couple of things to bear in mind, which will be pointed out as we go along. Do note, however, that if you have not yet updated to Xcode 7 and there are many professional environments in which updating isn't done without a significant degree of caution—then now is the time to do it, Xcode 6 will not build WatchKit apps beyond the first version of watchOS and we will be developing for the vastly superior watchOS 2.

Creating a new Xcode project

Assuming you have Xcode 7 up and running, we will now let it do much of the work involved in setting up a project that will include the targets, schemes and source files needed to create the basics of a Watch app and its companion iPhone app.

iPhone, by the way, not iPad. Only the iPhone (5 and above) can pair with the Watch, and if the app is run on an iPad, the presence of the Watch app will simply be ignored.

A template...

Looking over the project

We'll take a moment to have a look at the project, which will differ in some ways to projects you have created just for the iPhone.

Three apps?

The first thing to notice is that you have more source code files than you are accustomed to seeing when you first create a purely iOS app. These are rather conveniently organized into groups in the Navigator pane as follows:

iOS app

In the group named HelloWatch (assuming you used that name when creating the project) you will find the list of source code, xcasset, and info.plist files with which you are already familiar, and these files all make up the iOS app that will run on the iPhone. Remember, watchKit apps for watchOS need a companion iPhone app, however much the Watch app may be your focus, and possibly your user's.

There is little to add at this stage, and in this chapter we will not be changing any of the files in this group.

WatchKit app

The group named HelloWatch WatchKit App contains the Storyboard (and...

Adding some content on screen

So let's get some content onto the screen. We have covered a lot of ground already; negotiated a couple of tricky hurdles and gained a good overview of the project. It really is time to create something more interesting to look at in the Watch Simulator than the less-than-inspiring black screen that shows the time in one corner.

Preparing the interface

Follow the given instructions to prepare the interface:

  1. Open a new tab in Xcode (Command-T). In the project Navigator, select the Interface.storyboard file from the HelloWatch WatchKit App group (make sure you don't select the Main.storyboard from the HelloWatch group).
  2. From the Editor menu, select Show Document Outline if it is not selected already.
    Preparing the interface
  3. Open the Interface Controller Scene in the Document Outline as shown, which will help you navigate around the interface as you add UI elements to it (selecting some of the smaller elements directly can get a little tricky and the outline will help you here)...

Give the UI some visual appeal

Our button as it stands is working perfectly, but doesn't exactly cry out to be tapped. The button's default (clear) background color and default button font may identify to an experienced user that it is indeed a button, but let's add a little sparkle to what is still a very monochromatic interface so that everyone new to the Watch - and we can, at the moment, be sure that a large proportion of our users will be just that - will both immediately recognize the button for what it is and be motivated to explore it.

Adding a group

This is a good opportunity to spend a little time looking at one aspect of watchOS development that is very different to its iOS counterpart—UI layout design.

It is not possible with WatchKit to programmatically create an interface or indeed make many fine adjustments to the layout once it has loaded. All this needs to be done before building the app, using the graphical user interface we have been using up until...

Adding some animation magic

We all know, as developers, the pain of finding that an idea that we had thought simple and quick to implement turns out to be much harder than we had imagined. But when programming with WatchKit, you will often find that some quite advanced-sounding technologies are, in fact, extremely easy to use.

WKInterfaceController animation methods are just that, and so we can add some flair to our app by changing the color of the button border – which is to say, the BorderGroup background color - using a call to animateWithDuration.

First, let's add some code to our InterfaceController class, and then we will take a look at what we have done.

  1. Control-drag from the Group in the Document Outline to the code in the assistant editor, to create an Outlet connection:
    Adding some animation magic
  2. Enter the name borderGroup as shown, and hit Connect.
    Adding some animation magic

    Xcode creates a new IBOutlet (connection) between the interface and the source code:

    @IBOutlet var borderGroup: WKInterfaceGroup!
  3. Next, below the HelloButtonTapped...

Setting it all up


This will be largely familiar territory to anyone who has already created projects for iOS, with just a couple of things to bear in mind, which will be pointed out as we go along. Do note, however, that if you have not yet updated to Xcode 7 and there are many professional environments in which updating isn't done without a significant degree of caution—then now is the time to do it, Xcode 6 will not build WatchKit apps beyond the first version of watchOS and we will be developing for the vastly superior watchOS 2.

Creating a new Xcode project

Assuming you have Xcode 7 up and running, we will now let it do much of the work involved in setting up a project that will include the targets, schemes and source files needed to create the basics of a Watch app and its companion iPhone app.

iPhone, by the way, not iPad. Only the iPhone (5 and above) can pair with the Watch, and if the app is run on an iPad, the presence of the Watch app will simply be ignored.

A template is provided...

Looking over the project


We'll take a moment to have a look at the project, which will differ in some ways to projects you have created just for the iPhone.

Three apps?

The first thing to notice is that you have more source code files than you are accustomed to seeing when you first create a purely iOS app. These are rather conveniently organized into groups in the Navigator pane as follows:

iOS app

In the group named HelloWatch (assuming you used that name when creating the project) you will find the list of source code, xcasset, and info.plist files with which you are already familiar, and these files all make up the iOS app that will run on the iPhone. Remember, watchKit apps for watchOS need a companion iPhone app, however much the Watch app may be your focus, and possibly your user's.

There is little to add at this stage, and in this chapter we will not be changing any of the files in this group.

WatchKit app

The group named HelloWatch WatchKit App contains the Storyboard (and an empty xcassets...

Adding some content on screen


So let's get some content onto the screen. We have covered a lot of ground already; negotiated a couple of tricky hurdles and gained a good overview of the project. It really is time to create something more interesting to look at in the Watch Simulator than the less-than-inspiring black screen that shows the time in one corner.

Preparing the interface

Follow the given instructions to prepare the interface:

  1. Open a new tab in Xcode (Command-T). In the project Navigator, select the Interface.storyboard file from the HelloWatch WatchKit App group (make sure you don't select the Main.storyboard from the HelloWatch group).

  2. From the Editor menu, select Show Document Outline if it is not selected already.

  3. Open the Interface Controller Scene in the Document Outline as shown, which will help you navigate around the interface as you add UI elements to it (selecting some of the smaller elements directly can get a little tricky and the outline will help you here).

    Tip

    If you don...

Left arrow icon Right arrow icon

Key benefits

  • Explore the opportunities opened up to developers by Apple’s latest device: the Apple Watch
  • Be a crackerjack at developing software across a broad range of watch app categories
  • From an eminent author, master all stages of development, from the first stage through to a completed project

Description

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.

Who is this book 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!

What you will learn

  • Understand the concept of the Apple Watch as an autonomous device as well as it being paired with the iPhone
  • Get your app up and running
  • Design exciting, inspiring, and attractive layouts for your apps
  • Make your user interface more engaging using images and animation
  • Enable your Watch and iPhone apps to transport and share data
  • Leverage the feature-rich set of WatchKit technologies provided by Apple
  • Connect your apps to the Internet
  • Submit your app to the App Store

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Feb 29, 2016
Length: 298 pages
Edition : 1st
Language : English
ISBN-13 : 9781785887055
Vendor :
Apple
Category :
Languages :
Concepts :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Feb 29, 2016
Length: 298 pages
Edition : 1st
Language : English
ISBN-13 : 9781785887055
Vendor :
Apple
Category :
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just ₱260 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just ₱260 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 6,685.97
Android Wearable Programming
₱1683.99
Arduino Wearable Projects
₱2500.99
Building Apple Watch Projects
₱2500.99
Total 6,685.97 Stars icon

Table of Contents

11 Chapters
1. Exploring the New Platform Chevron down icon Chevron up icon
2. Hello Watch Chevron down icon Chevron up icon
3. C-Quence – A Memory Game Chevron down icon Chevron up icon
4. Expanding on C-Quence Chevron down icon Chevron up icon
5. On Q – A Productivity App Chevron down icon Chevron up icon
6. Watching the Weather Chevron down icon Chevron up icon
7. Plot Buddy – All about Location Chevron down icon Chevron up icon
8. Images, Animation, and Sound Chevron down icon Chevron up icon
9. Wear It, Test It, Tweak It, Ship It Chevron down icon Chevron up icon
10. This Is Only the Beginning Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.