wearables_pic

The mobile industry is built on engaging users by putting information that impacts their work, life and play into their pocket. Wearables make this information even more accessible by putting it on their wrist. This spring, Apple is launching a major new product that will be on tens of millions[1] of people’s wrists by the end of the year. That product is Apple Watch and it will support third party apps called watch apps.

What Is a Watch App?

A watch app is much like a mobile app, presented in a full screen view on the face of the Apple Watch. The files that make up the watch app define the presentation of the app, but the watch app by itself can’t do anything without being connected to an iPhone. The WatchKit extension lives on the phone and contains all the watch app logic that controls what is displayed on the Apple Watch face and how the app responds to user input.

What Can a Watch App Do?

A watch app can display table cells, paginated views, static and animated images, clocks and timers. The app’s storyboard can directly trigger actions in the extension with buttons, switches, sliders, table rows and modal menu items. These elements can be composed into fairly complex apps while still offloading all the logic to the WatchKit extension running on the iPhone. Watch apps can also receive text input through dictation using the watch’s built-in microphone.

What Can’t a Watch App Do?

Apple created a unique app architecture that moves all the logic to a paired iPhone to drastically reduce the power consumption of third party watch apps. There are also some other battery-conserving limitations that need to be considered when building watch apps. Watch apps don’t have access to the watch hardware or sensors, including the heart rate monitor, audio from the built-in mic, speaker or the vibrating Taptic Engine. Apple has hinted that these may be accessible “later [this] year”[2] but at this point they are off limits. Additionally, watch app extensions can’t receive multi-touch gestures from the watch screen or directly manipulate views on the screen. Also keep in mind that watch users can’t grant permissions from the watch and WatchKit extensions can’t run in background modes.

Watch App Composition

Watch_App_Composition

Watch apps are distributed through the App Store as part of an iPhone app. The WatchKit extension within the app contains a subclass of WKInterfaceController that runs on the iPhone and controls all the watch app logic. The watch app logic configures the watch app presentation when the watch app is loaded, and handles all user interactions coming from the watch. The watch app logic interacts with the user but can also interact with the host app and with external services through web requests.

Watch App Lifecycle

Watch_App_Lifecycle

Watch apps undergo a lifecycle similar to iPhone and iPad apps. The lifecycle begins when the app is launched by touching its icon on the watch home screen or by tapping a notification or hard pressing on a glance. Launching the app loads its storyboard from the watch’s local storage. Once the watch has loaded the initial view controller from the storyboard, it sends awakeWithContext to the WatchKit extension running on the paired iPhone. This message allows the extension to configure the user interface before the watch displays the watch app UI. The watch sends willActivate to the WatchKit extension when it displays the watch app UI on its screen.

Various action methods facilitate interaction between the user and the WatchKit extension running on the iPhone. These interactions are unique to each watch app and make up the bulk of the watch app lifecycle’s lifetime, which is expected to be on the order of seconds. The watch app lifecycle ends when the user stops interacting with the watch. Switching to a different app or moving the wrist away from the active position ends the user interaction with the watch app. The watch app sends didDeactivate when the watch app lifecycle is complete.

Adding a Watch App to an Existing iOS Application

Developers can start working on watch apps by downloading a pre-release version of Xcode 6.2. Adding a watch app to an existing iOS application and running it requires only three steps using Xcode 6.2:

  1. Go to File > New > Target.
  2. Choose the Watch App template from the Apple Watch section and click Next and click Finish.
  3. Switch to the Watch App scheme and hit Run (►). If you don’t see a watch display in iOS Simulator, you can enable it by going to Hardware > External Displays > Apple Watch.

adding_watch_app_to_iOS

Once you’ve added the watch app target, you’ll see new WatchKit Extension and Watch App folders in the Xcode project navigator. The WatchKit Extension folder contains the code that will run on the iPhone and control the watch app and the Watch App folder contains the storyboard and assets which will be stored and loaded on the watch. You will be able to submit apps with WatchKit extensions to the App Store once Apple officially releases Xcode 6.2. This is expected to happen one month before the April 2015 Apple Watch release.

coffee_finder_app

[1] http://bgr.com/2014/11/20/apple-watch-sales-2015/

[2] http://www.apple.com/pr/library/2014/11/18Developers-Start-Designing-Apps-for-Apple-Watch.html