Developing Apps With WatchKit A Whirlwind Tour Adam Shaw Kabuki Vision @KabukiVision Journaling NoteMaster Dressed
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
WatchKit Extensions WatchKit 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
WatchKit Extensions • WatchKit App • Glance (optional) • Notification (optional)
Architecture WatchKit WatchKit WatchKit App WatchKit Extension Code! Storyboard Resources Resources iPhone App Code Resources
Architecture WatchKit WatchKit Extension Code Resources Limited Shared Communication Data iPhone App Code Resources
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)
Things you CANNOT do Hardware sensors (heart rate, step counter, accelerometer, etc)
Things you CANNOT do Wireless Communications
Things you CANNOT do Core Animation CAN animate as sequence of images (like an animated GIF)
Things you CANNOT do Multi-touch gestures Swiping, dragging, etc.
Things you CANNOT do Direct access to speaker or microphone
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
User Interface Storyboards UI created using storyboards in Xcode’s Interface Builder
User Interface Interface Elements • Text labels, buttons, images • Switches, sliders, separators, maps • “Text” input (via voice) • Groups • Tables
User Interface Interface Elements • 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 Interface Interface Layout • 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 Interface Interface Navigation Hierarchical Page-based Modal Can’t mix and match hierarchical and page-based (at the same level)
User Interface Images WatchKit App WatchKit Extension Installed Images Code! Cached Images
Sharing Data WatchKit extension & iOS app WatchKit Extension App Group XYZ Sandbox Shared Data iPhone App App Group XYZ Sandbox
Communication WatchKit extension & iOS app WatchKit Extension Sandbox openParentApplication:reply application:handleWatchKitExtensionRequest:reply: iPhone App Sandbox
Communication WatchKit extension & iOS app WatchKit Extension Sandbox Darwin Notifications (MMWormhole) iPhone App Sandbox
Networking WatchKit Extension Sandbox ??? openParentApplication:reply Shared Data application:handleWatchKitExtensionRequest:reply: iPhone App Sandbox
Gotchas • Unpredictable and merciless lifecycle • WatchKit extension can and will be killed at any time without warning • User puts down wrist • Screen timeout
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
Gotchas • Permissions (contacts, images, location etc.) • Only main iOS app can trigger these
THANKS! Adam Shaw Kabuki Vision @KabukiVision Journaling NoteMaster Dressed
Recommend
More recommend