Notes from WWDC 2015: Building Watch Apps

If you were too slammed to pay attention to WWDC this year, you can get a quick overview of how to build apps for watchOS 2 with the notes below. The Building Watch Apps session from WWDC 2015 is essential for digging in to how development works in watchOS 2. It’s changed significantly from the first version of watchOS, so if you’ve developed for watchOS 1, you’ll need to do things differently for the new version.

If you’re too busy to watch the video, take a few minutes to scan the notes below to get a quick overview of what’s different in watchOS 2 and what you’ll need to do to build apps for the latest version of watchOS.


WWDC 2015: Building Watch Apps

Architecture

Your existing iPhone app contains your WatchKit extension and the watch app.

The watch app is comprised of 2 pieces:

  • WatchKit extension: runs on apple watch and executes code and responds to user interaction
  • Watch app: UI loaded from bundle containing storyboard & images

Additionally:

  • UI is stored in Watch App
  • Code updates the UI from the extension

WatchKit Framework

  • One controller per screen of content
  • Manages UI elements through outlets
  • Uses target-action design pattern

CallMeLately (sample app): communicates with a server via NSURLSession

Adding a Watch App

  • Add Watch App target
  • Configure interface elements
  • Build and run

Simulator

  • Full simulator
  • 38mm and 42mm
  • Simulate Touch Pressure
  • Clock faces (so you can see how your complications look)
  • Multiple apps

Touch Pressure

In the Simulator, Hardware > Simulate Touch Pressure > Deep Press

Demo

Watch app contains storyboard. Layout is significantly different from iOS – there are no Auto Layout constraints. Layout on Watch is entirely flow-based.

WatchKit extension contains interface controllers & any other code we might want to add.

You can configure notification payloads to test in the Simulator.

If you want to create a new iOS Simulator paired with Apple Watch:

Window > Devices > + (bottom left)

Change Watch Interface and Notification Payload in Edit Scheme > Info
(or you can duplicate the scheme)

App Lifecycle

a lot like the iOS app lifecycle

WatchKit Layout

Model

  • Different from UIKit and AppKit
  • Flow-based layout
  • groups are containers of elements

Programming model

you don’t write object creation code

You have fine tuned control of:

  • positioning and sizing
  • layout hierarchy
  • animation

See Layout and Animation Techniques for WatchKit for more on animation

Creating My UI

  • Main app UI
  • Glance
  • Notification

Attributes Inspector: set horizontal/vertical position, size, etc

Glances are templated: upper & lower. You can choose from a list of options for each.

WatchConnectivity Framework

There are four core uses for communication.

APIs are on both platforms, can be used each direction:

  • Application context
  • Send message
  • File transfer
  • Transfer User info

See “Introducing Watch Connectivity” for more about these.

Instruments

You can profile with Instruments just like with iOS apps.

Keep in mind:

  • engagement times are short
  • performance is critical
  • you can profile on device or simulator

You can send and receive messages to update the iPhone app with what’s visible on Watch.

Pro Tip: Hold Control while clicking on Run to Run without building

You can debug in both the iOS and watchOS simulators at the same time.

WWDC CallMeLately

  • Added a Watch app
  • Created an interface for our app and glance
  • Used WatchConnectivity to communicate
  • Debugged our iOS and watchOS apps
  • Profiled in Instruments

watchOS 2 Features

  • Complications
  • Digital crown
  • Animations
  • Heart Rate Sensors
  • Haptics
  • Media Playback (video/audio)
  • Audio Recording
  • Security (keychain)

Recap

  • Architecture
  • Adding a Watch app
  • App Lifecycle
  • Use interface elements
  • Build and run
  • Debugging
  • Use watchOS capabilities

Get up to date on Swift with the 5-Part Guide below – and spend your nights and weekends relaxing and enjoying the time off.