27
Developing Apps With WatchKit Adam Shaw Kabuki Vision A Whirlwind Tour @KabukiVision Dressed NoteMaster Journaling

Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

Developing Apps With WatchKit

Adam ShawKabuki Vision

A Whirlwind Tour

@KabukiVision

Dressed NoteMaster Journaling

Page 2: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

WatchKit• SDK for building apps for Apple Watch

• Similar, but different from iOS app development

• Very limited

• Can’t build true “native” apps

• Need

• Xcode (Mac)

• Apple Watch

• iPhone

Page 3: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

WatchKit ExtensionsWatchKit app is an extension to an iPhone app.

“Starting later next year, developers will be able to create fully native apps for Apple Watch.”

— Apple, Nov 2014

Page 4: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

WatchKit Extensions

• WatchKit App

• Glance (optional)

• Notification (optional)

Page 5: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

Architecture

WatchKit AppStoryboard

Resources

WatchKit ExtensionCode!

Resources

iPhone AppCode

Resources

WatchKitWatchKit

Page 6: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

Architecture

WatchKit ExtensionCode Resources

WatchKit

iPhone AppCode Resources

Shared Data

Limited Communication

Page 7: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

Architecture

• WatchKit app distributed as part of iOS app

• WatchKit code in “WatchKit extension”

• None of your code runs on the watch!

• All of your WatchKit extension code runs on iPhone (in separate background process from main app)

Page 8: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

Things you CANNOT do

Hardware sensors (heart rate, step counter, accelerometer, etc)

Page 9: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

Things you CANNOT do

Wireless Communications

Page 10: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

Things you CANNOT do

Core Animation

CAN animate as sequence of images (like an animated GIF)

Page 11: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

Things you CANNOT do

Multi-touch gestures Swiping, dragging, etc.

Page 12: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

Things you CANNOT do

Direct access to speaker or microphone

Page 13: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

What CAN you do?• Basically:

• Put stuff on the screen

• Respond to simple button taps

• Use iPhone features (GPS, networking, etc.)

• Change stuff on the screen

Page 14: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

UI created using storyboards in Xcode’s Interface Builder

User InterfaceStoryboards

Page 15: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

User InterfaceInterface Elements

• Text labels, buttons, images

• Switches, sliders, separators, maps

• “Text” input (via voice)

• Groups

• Tables

Page 16: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

• Everything must be defined in the storyboard

• No dynamic creation of interface elements in code (mostly)

• Most attributes (color, image, text, etc) can be controlled in code

• “Hidden” attribute can be used to effectively add/remove elements from the interface

• Table “rows” are the only elements that can be dynamically added/removed in code

User InterfaceInterface Elements

Page 17: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

• All layout defined in storyboards

• No auto layout, no explicit positioning

• Relative positioning - interface objects laid out vertically or horizontally

• Content expands downward, allowing vertical scrolling

• Two different watch sizes

User InterfaceInterface Layout

Page 18: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

User InterfaceInterface Navigation

Hierarchical Page-based Modal

Can’t mix and match hierarchical and page-based (at the same level)

Page 19: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

User InterfaceImages

WatchKit AppInstalled Images

WatchKit Extension

Code!Cached Images

Page 20: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

Sharing DataWatchKit extension & iOS app

WatchKit ExtensionSandbox

iPhone App

Shared Data

Sandbox

App Group XYZ

App Group XYZ

Page 21: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

CommunicationWatchKit extension & iOS app

WatchKit ExtensionSandbox

iPhone AppSandbox

openParentApplication:reply

application:handleWatchKitExtensionRequest:reply:

Page 22: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

CommunicationWatchKit extension & iOS app

WatchKit ExtensionSandbox

iPhone AppSandbox

Darwin Notifications (MMWormhole)

Page 23: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

Networking

WatchKit ExtensionSandbox

iPhone AppSandbox

openParentApplication:reply

application:handleWatchKitExtensionRequest:reply:

???

Shared Data

Page 24: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

Gotchas

• Unpredictable and merciless lifecycle

• WatchKit extension can and will be killed at any time without warning

• User puts down wrist

• Screen timeout

Page 25: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

Gotchas• UI Performance

• Communication speed and latency between iPhone and Apple Watch

• Dynamically generated images sent over to watch from iPhone

• Watch not fast at loading images, period

• Reacting to button taps are a two-way trip

Page 26: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

Gotchas

• Permissions (contacts, images, location etc.)

• Only main iOS app can trigger these

Page 27: Developing Apps With WatchKit · • Similar, but different from iOS app development ... • Glance (optional) ... Core Animation CAN animate as sequence of images (like an animated

THANKS!

Adam ShawKabuki Vision

@KabukiVision

Dressed NoteMaster Journaling