Difference between revisions of "WatchOS 2 Apps – An Overview"

From Techotopia
Jump to: navigation, search
m (Text replacement - "<google>BUY_WATCHOS2</google>" to "<htmlet>watchos2</htmlet>")
m (Text replacement - "<table border="0" cellspacing="0" width="100%">" to "<table border="0" cellspacing="0">")
Line 1: Line 1:
<table border="0" cellspacing="0" width="100%">
+
<table border="0" cellspacing="0">
 
<tr>
 
<tr>
 
<td width="20%">[[WatchOS 2 App Development Essentials|Previous]]<td align="center">[[watchOS 2 App Development Essentials|Table of Contents]]<td width="20%" align="right">[[Building an Example watchOS 2 WatchKit App|Next]]</td>
 
<td width="20%">[[WatchOS 2 App Development Essentials|Previous]]<td align="center">[[watchOS 2 App Development Essentials|Table of Contents]]<td width="20%" align="right">[[Building an Example watchOS 2 WatchKit App|Next]]</td>
Line 94: Line 94:
  
 
<hr>
 
<hr>
<table border="0" cellspacing="0" width="100%">
+
<table border="0" cellspacing="0">
 
<tr>
 
<tr>
 
<td width="20%">[[WatchOS 2 App Development Essentials|Previous]]<td align="center">[[watchOS 2 App Development Essentials|Table of Contents]]<td width="20%" align="right">[[Building an Example watchOS 2 WatchKit App|Next]]</td>
 
<td width="20%">[[WatchOS 2 App Development Essentials|Previous]]<td align="center">[[watchOS 2 App Development Essentials|Table of Contents]]<td width="20%" align="right">[[Building an Example watchOS 2 WatchKit App|Next]]</td>

Revision as of 14:44, 5 May 2016

PreviousTable of ContentsNext
WatchOS 2 App Development EssentialsBuilding an Example watchOS 2 WatchKit App


Purchase the full edition of this watchOS 2 App Development Essentials book in eBook ($12.99) or Print ($27.99) format
watchOS 2 App Development Essentials Print and eBook (ePub/PDF/Kindle) editions contain 35 chapters.

Buy Print


Before embarking on the creation of a watchOS 2 app it is important to gain a basic understanding of what an Apple Watch app consists of and, more importantly, how it fits into the existing iOS application ecosystem. Within this chapter, a high level overview of watchOS 2 apps will be provided, together with an outline of how these apps are structured and delivered to the customer.


Contents


What is a watchOS App?

watchOS is the name given to the operating system that runs on the Apple Watch device. Prior to the introduction of the Apple Watch family of devices, it was only possible to develop mobile applications for iPhone, iPad and iPod Touch devices running the iOS operating system. With the introduction of the Apple Watch, however, it is now possible for iOS developers to also create apps that run on watchOS.

In simplistic terms, watchOS apps are launched on an Apple Watch device either as the result of an action by the user or in response to some form of local or remote notification. Once launched, the watchOS app presents a user interface on the watch screen displaying information and controls with which the user can interact to perform tasks.

WatchKit App or watchOS App?

iOS apps are developed using a variety of software development kit frameworks. Although a number of frameworks are also available for developing watchOS apps, the primary framework used on watchOS is the WatchKit framework.

So far in this chapter we have referred to apps running on an Apple Watch device as watchOS apps. In actual fact, these apps are more correctly referred to as WatchKit apps. That being said, there seems to be little consistency in the terms used to refer to an app that runs on an Apple Watch. When reading Apple’s marketing and technical documentation it is not uncommon to find Apple Watch apps referred to as watch apps, WatchKit apps or watchOS apps. For the avoidance of confusion, apps designed to run on an Apple Watch will be referred to as WatchKit apps throughout the remainder of this book.


WatchKit Apps and iOS Apps

It is important to understand that WatchKit apps are not standalone entities. A WatchKit app can only be created as an extension to an existing iOS app. It is not, therefore, possible to create a WatchKit app that is not bundled as part of a new or existing iOS application.

Consider, for example, an iPhone iOS application designed to provide the user with detailed weather information. Prior to the introduction of the Apple Watch, the only way for the user to access the information provided by the app would have been to pick up the iPhone, unlock the device, launch the iOS app and view the information on the iPhone display. Now that information can be made available via the user’s Apple Watch device.

In order to make the information provided by the iOS app available via the user’s Apple Watch, the developer of the weather app would add a WatchKit app extension to the iOS app, design a suitable user interface to display the information on the watch display and implement the logic to display the appropriate weather information and respond to any user interaction. Instead of having to launch the iOS app from the iPhone device to check the weather, the user can now launch the WatchKit app from the Apple Watch and view and interact with the information.

Clearly, the display size of an Apple Watch is considerably smaller than that of even the smallest of iPhone models. As such, a WatchKit app will typically display only a subset of the content available on the larger iPhone screen. For more detailed information, the user would still need to make use of the iOS application.

The watchOS SDK Frameworks

Running directly on the hardware of the Apple Watch is the watchOS 2 operating system. Included with the operating system is a set of frameworks that combine to make up the watchOS SDK. WatchKit apps are developed by making use of the various frameworks contained within the watchOS SDK. This can best be presented visually as outlined in the diagram shown in Figure 2-1:


The watchOS 2 Stack diagram

Figure 2-1


The key layer for the app developer is the watchOS SDK which contains a number of different frameworks. Figure 2 2 illustrates the frameworks contained within the watchOS 2 SDK that are available for use when developing apps for watchOS:


watchOS 2 SDK frameworks

Figure 2-2


With the exception of the WatchKit and Watch Connectivity frameworks, many of these frameworks will be familiar to iOS developers, though it is important to be aware that not all of the features of a framework that are available on iOS are supported on watchOS.

The Key Components of a WatchKit App

A WatchKit app is comprised of the Watchkit app and a WatchKit extension.

Extensions are a feature introduced as part of the iOS 8 SDK release and were originally intended solely to allow certain capabilities of an application to be made available for use within other applications running on the same device. The developer of a photo editing application might, for example, have devised some unique image filtering capabilities and decide that those features would be particularly useful to users of the iOS Photos app. To achieve this, the developer would implement these features in a Photo Editing extension which would then appear as an option to users when editing an image within the Photos app. Other extension types are also available for performing document storage, creating custom keyboards and embedding information from an application into the iOS notification panel.

With the introduction of the Apple Watch and watchOS, however, the concept of extensions has now been extended to make the functionality of an iOS app available in the form of a WatchKit app.

Extensions are separate executable binaries that run independently of the corresponding iOS application. Although extensions take the form of an individual binary, they must be supplied and installed as part of an iOS application bundle. The iOS application with which an extension is bundled is referred to as the containing app or parent app. The containing app must provide useful functionality and must not be an empty application provided solely for the purpose of delivering an extension to the user.

When an iOS application containing a WatchKit app has been installed on an iPhone device, both the WatchKit app and the corresponding WatchKit extension are subsequently transferred and installed onto the paired Apple Watch device. When the user launches a WatchKit app on a watch device, the WatchKit framework will launch the corresponding WatchKit extension before beginning the app initialization process.

Basic WatchKit App Structure

As previously outlined, the implementation of a WatchKit app is divided between the WatchKit app and WatchKit extension, both of which reside and execute on the Apple Watch device. This raises the question of how the responsibilities of providing the functionality of the WatchKit app are divided between these components. These responsibilities may be summarized as follows:

  • WatchKit app – Consists of the storyboard file containing the user interface and corresponding resources (such as image and configuration files).
  • WatchKit Extension – Contains all of the code required to provide the functionality of the WatchKit app and responding to user interaction. The extension may also contain resources such as images and media files.

WatchKit App Entry Points

There are number of different ways in which the user may enter a WatchKit app, each of which will be detailed in later chapters and can be summarized as follows:

  • Home Screen – Once installed, the WatchKit app will be represented by an icon on the home screen of the Apple Watch display. When this icon is selected by the user the app will load and display the main user interface scene.
  • Glance – When developing a WatchKit app, the option is available to add a Glance interface to the app. This is a single, non-scrollable, read-only scene that can be used to display a quick-look summary of the information normally presented by the full version of the app. Glances are accessed when the user performs an upward swiping motion on the watch display and, when tapped by the user, launch the corresponding WatchKit app.
  • Notifications – When a notification for a WatchKit app appears on the Apple Watch device, the app will be launched when the notification is tapped.

Summary

A WatchKit app is an application designed to run on the Apple Watch family of devices. A WatchKit app cannot be a standalone application and must instead be created as an extension of an existing iOS application. The WatchKit app is installed on the Apple Watch device and consists of a storyboard file containing the user interface of the app together with a set of resource files. The WatchKit extension is also installed on the Apple Watch device and contains all of the code logic required to implement the behavior of the WatchKit app.


Purchase the full edition of this watchOS 2 App Development Essentials book in eBook ($12.99) or Print ($27.99) format
watchOS 2 App Development Essentials Print and eBook (ePub/PDF/Kindle) editions contain 35 chapters.

Buy Print



PreviousTable of ContentsNext
WatchOS 2 App Development EssentialsBuilding an Example watchOS 2 WatchKit App