Developer

Develop WatchKit applications for Apple Watch: What you need to know

WatchKit gives developers early access to the tools needed for developing apps for Apple Watch. Cory Bohon dives into the specifics about these types of apps.

watchkithero112414.jpg
Image: Cory Bohon/TechRepublic

Apple's release of WatchKit gives developers the ability to start developing and extending their iPhone applications to the Apple Watch when the device is released in the first part of 2015. I was stunned when I realized that you can build full applications for the device. Early speculation led me to believe that we'd only have access to Interactive Notifications and the Glances feature. (There are caveats with full apps, which I'll cover later in this article.)

Overall, WatchKit looks amazing for what it is, and provides another route for developers to further extend their existing applications into the Apple ecosystem.

What do we have access to with WatchKit?

WatchKit gives developers access to developing three types of interactions on Apple Watch: Interactive Notifications, Glances, and full apps (Figure A).

Figure A

watchkitfiga112414.png
Image: Apple Developer Documentation

Interactive Notifications work essentially like push notifications, allowing context-specific buttons and user actions when a notification comes into the watch. Take Facebook for instance: If there's a Facebook notification for a friend request, you could have contextually-specific buttons for Accept or Decline, making it easier for users to act upon notifications without having to launch an application first to do so.

Glances are the Notification Center Today View of the Apple Watch, letting you place specific one-page apps into the screen, and quickly swipe through them in order to get new information. Examples of Glances that I've seen are the Stock and Weather features on the Apple Watch — these one-page screens list your favorite stocks and current location's weather in a simple, single-Glance view. Glances are very comparable to the Today View extensions in iOS 8.

Full Apps is what developers are most excited about with WatchKit. You can create nearly full-featured applications with more limited UI and UX than what you might be used to on iOS applications.

How do these applications work?

I was surprised to learn that WatchKit applications would be included in the early access version of WatchKit. Initially (from reports in the developer community), I thought that applications wouldn't be supported on Apple Watch until late 2015. There are limitations to early apps on the Apple Watch.

The biggest caveat is that the current WatchKit apps require an iPhone to function. This means that when you design your WatchKit apps, the Storyboard files for the watch application are loaded onto the Apple Watch; however, the code used to update interface elements and perform tasks is run on the iPhone instead. This means that in order for your application to work, the user must be paired to their iPhone. This lack of native functionality may be enough to turn some developers off to the idea of developing a current generation WatchKit app, but I believe that Apple may still include native functionality for the Apple Watch, and may deliver more news on that at WWDC '15.

Apple Watch apps are built similar to extensions in iOS 8, allowing a developer of an existing iPhone application to include an extra WatchKit Target in their project. Once built and loaded onto a paired iPhone, the WatchKit application can be run on the Apple Watch, processing all code on the actual iPhone instead of the watch. I believe this could help battery life by offloading CPU-expensive tasks to the iPhone.

WatchKit apps have a dozen UI components, compared to the myriad of built-in and custom UI components that you can have on iOS and OS X. Here are some of the components you can use to build Apple Watch applications:

  • Group: A container that manages the layout of other items.
  • Table: Displays one or more rows of data.
  • Image: Displays a static or animated image.
  • Separator: A line for separating content in your interface.
  • Button: A tappable area with a title and/or image.
  • Switch: A control for indicating a binary value.
  • Slider: A control for selecting a floating-point value from a range of continuous discrete values.
  • Label: Displays a static text string.
  • Date: Displays the current date and time.
  • Timer: Displays a string that counts up or down to a specified time.
  • Map: Displays the user's location or the location of specific place marks.
  • Menu: Displays a list of menu items (used with Force Touch).
  • Menu Item: Executes an action method of the parent interface controller (Menu).

These controls are what you will use to build out applications in your Storyboard (Figure A) — you don't have to worry about AutoLayout, XIBs, or anything else. The WatchKit Storyboard will automagically layout your on-screen elements by flowing them one after the other.

What do I need to get started?

WatchKit is included with the Xcode 6.2 beta, which also includes the iOS 8.2 SDK and simulators for Apple Watch and iOS 8.2. You can download the installer for Xcode 6.2 beta, and then create a new Apple Watch extension by following these steps:

  1. Open your base application project in Xcode.
  2. Select File | New | New Target.
  3. In the Target template chooser, select Apple Watch | Watch App (Figure B).

Figure B

watchkitfigb112414.png
Image: Cory Bohon/TechRepublic

You'll see a new Watch extension folder with your Interface Controllers that run on the iPhone. There will be another folder ending in "App" that contains your Interface and Image assets that are loaded onto the Apple Watch.

Specs on the Apple Watch

  • The smaller Apple Watch (38mm) has a screen size of 340 px x 272 px; the larger Apple Watch (42mm) has a screen size of 390 px x 312 px (Figure C).
  • There is a 20MB image cache available on the Apple Watch for holding assets that may need to be displayed.
  • The watch uses a new font called San Francisco.
  • You cannot display videos on the watch, but it can iterate over images to create an animation.
  • Both sizes of the watch require different default asset sizes for icons, including the Notification Center icon, the Long look icon, and Home screen icons. See the table below (Figure D) for more information on the watch default image requirements.
  • You should create all image assets with an @2x resolution. There is no need to include non @2x assets in your Watch applications.

Figure C

watchkitfigc112414.png
Image: Apple Developer Documentation

Figure D

watchkitfigd112414.png
Image: Apple Developer Documentation

Learn more about WatchKit

Apple has a special page on its developer site that allows developers to get more resources and information about WatchKit and the Apple Watch. In addition, you'll find the following resources invaluable when creating WatchKit apps.

If you haven't built an Extension-based app before, then check out our Part 1 and Part 2 guides on building iOS 8 extensions. Knowledge of Extensions is invaluable when building WatchKit applications.

About Cory Bohon

Cory Bohon is an indie developer specializing in iOS and OS X development. He runs a software company called Cocoa App and is also a developer at MartianCraft. He was introduced to technology at an early age and has been writing about his favorite te...

Editor's Picks

Free Newsletters, In your Inbox