developing apps with watchkit · • similar, but different from ios app development ... • glance...
TRANSCRIPT
Developing Apps With WatchKit
Adam ShawKabuki Vision
A Whirlwind Tour
@KabukiVision
Dressed NoteMaster Journaling
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 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
WatchKit Extensions
• WatchKit App
• Glance (optional)
• Notification (optional)
Architecture
WatchKit AppStoryboard
Resources
WatchKit ExtensionCode!
Resources
iPhone AppCode
Resources
WatchKitWatchKit
Architecture
WatchKit ExtensionCode Resources
WatchKit
iPhone AppCode Resources
Shared Data
Limited Communication
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
UI created using storyboards in Xcode’s Interface Builder
User InterfaceStoryboards
User InterfaceInterface Elements
• Text labels, buttons, images
• Switches, sliders, separators, maps
• “Text” input (via voice)
• Groups
• Tables
• 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
• 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
User InterfaceInterface Navigation
Hierarchical Page-based Modal
Can’t mix and match hierarchical and page-based (at the same level)
User InterfaceImages
WatchKit AppInstalled Images
WatchKit Extension
Code!Cached Images
Sharing DataWatchKit extension & iOS app
WatchKit ExtensionSandbox
iPhone App
Shared Data
Sandbox
App Group XYZ
App Group XYZ
CommunicationWatchKit extension & iOS app
WatchKit ExtensionSandbox
iPhone AppSandbox
openParentApplication:reply
application:handleWatchKitExtensionRequest:reply:
CommunicationWatchKit extension & iOS app
WatchKit ExtensionSandbox
iPhone AppSandbox
Darwin Notifications (MMWormhole)
Networking
WatchKit ExtensionSandbox
iPhone AppSandbox
openParentApplication:reply
application:handleWatchKitExtensionRequest:reply:
???
Shared Data
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 ShawKabuki Vision
@KabukiVision
Dressed NoteMaster Journaling