Framework

WatchKit

Construct and manage your app’s user interface for watchOS. Respond to events generated by interface objects, gestures, and the system.

Overview

The WatchKit framework contains the classes that a WatchKit extension uses to manipulate the interface of a watchOS app. A watchOS app contains one or more interface controllers, each of which can have tables, buttons, sliders, and other types of visual elements. The WatchKit extension uses the classes of this framework to configure those visual elements and to respond to user interactions.

Topics

Extension Architecture

WKExtension

An object that manages behaviors that are shared among all of your app’s interface controllers.

WKExtensionDelegate

A collection of methods you can implement to manage the app-level behavior of your WatchKit extension.

WKInterfaceDevice

An object that provides information about the user’s Apple Watch.

Keeping Your watchOS App’s Content Up to Date

Ensure that your watchOS app has access to the most recent content available.

Supporting Multiple Screen Sizes

Customize your app for all Apple Watch screen sizes.

User Interface Basics

WKInterfaceObject

An object that provides information that is common to all interface objects in your watchOS app.

WKInterfaceController

A class that provides the infrastructure for managing the interface in a watchOS app.

WKAlertAction

An object that encapsulates information about a button displayed in an alert or action sheet.

WKAccessibilityImageRegion

An object that defines a portion of an image that you want to call out separately to an assistive app.

WKAccessibilityIsVoiceOverRunning

Returns a Boolean value indicating whether VoiceOver is running.

WKAccessibilityIsReduceMotionEnabled

Returns a Boolean value indicating whether reduced motion is enabled.

Controls

WKInterfaceLabel

An interface element that displays static text.

WKInterfaceDate

A label that displays the current date or time.

WKInterfaceTimer

A label that displays a countdown or count-up timer.

WKInterfaceButton

A button in the user interface of your watchOS app.

WKInterfacePaymentButton

A button that you can use to trigger payments through Apple Pay.

WKInterfaceSwitch

An interface element that toggles between an On and Off state.

WKInterfaceSlider

An interface element that lets users select a single floating-point value from a range of values.

WKInterfaceActivityRing

A view that displays data from a HealthKit activity summary object.

WKInterfaceMap

An interface element that displays a noninteractive map for the location you specify.

Containers

WKInterfaceGroup

A container for one or more interface objects.

WKInterfaceSeparator

An interface object that displays a visual separator within a group.

WKInterfaceTable

An object that creates and manages the contents of a single-column table interface.

WKInterfacePicker

An interface element that presents a scrolling list of items for the user to choose from.

Audio

Playing Background Audio

Enable background audio in your app to provide a seamless playback experience.

Adding a Now Playing View

Let users control the currently playing audio in your app.

WKInterfaceVolumeControl

An interface element that lets users control the audio volume from the watch or a paired iPhone.

WKAudioFilePlayer

An object that controls playback of a single audio item.

WKAudioFileQueuePlayer

An object that controls playback of one or more audio items.

WKAudioFilePlayerItem

An object that manages the presentation state of an audio file while it is being played.

WKAudioFileAsset

An object that stores a reference to an audio file and provides metadata information about that file.

Images and Movies

WKInterfaceImage

An image that can be displayed in the interface of your watchOS app.

WKImage

A wrapper for images you use with a picker interface.

WKImageAnimatable

A collection of methods you can use to control the playback of animated images.

WKInterfaceMovie

An interface element that lets you play video and audio content in your watchOS app.

WKInterfaceInlineMovie

An interface element that displays a video's poster image and supports inline playing of the video.

WKInterfaceHMCamera

An interface element that displays either a video stream or a single snapshot from an IP camera connected to HomeKit.

WKVideoGravity

Constants indicating the appearance of video content.

Graphics and Games

WKInterfaceSKScene

An object that lets you manage a SpriteKit scene in your watchOS app.

WKInterfaceSCNScene

An object that lets you manage SceneKit content for display in your app.

Event Handling

WKCrownSequencer

An object that reports the current state of the digital crown, including its rotational speed when it is in motion.

WKCrownDelegate

A collection of methods you can implement to track the user's interaction with the digital crown, receiving notifications when the user rotates the crown or when rotation stops.

WKGestureRecognizer

The base class for all other gesture recognizer classes.

WKLongPressGestureRecognizer

A gesture recognizer that looks for a touch event that occurs in the same relative area for an extended period of time.

WKPanGestureRecognizer

A gesture recognizer that looks for a touch event that moves around the screen.

WKSwipeGestureRecognizer

A gesture recognizer that looks for swiping gestures in one or more directions.

WKTapGestureRecognizer

A gesture recognizer that looks for a touch event occurring and ending in approximately the same area on the screen.

Notifications

Enabling Interactive Notifications

Define a dynamic notification controller that responds to user interactions.

WKUserNotificationInterfaceController

An interface controller object that manages a dynamic user interface for a local or remote notification.

Background Tasks

WKRefreshBackgroundTask

The abstract superclass for WatchKit's other background task classes.

WKApplicationRefreshBackgroundTask

A background task used to update your app’s state in the background.

WKURLSessionRefreshBackgroundTask

A background task that helps you respond to NSURLSession background transfers.

WKWatchConnectivityRefreshBackgroundTask

A background task used to receive background updates from the Watch Connectivity framework.

WKSnapshotRefreshBackgroundTask

A background task used to update your app’s user interface in preparation for a snapshot.

WKIntentDidRunRefreshBackgroundTask

A background task used to update your app after a SiriKit intent runs.

WKRelevantShortcutRefreshBackgroundTask

A background task used to periodically donate relevant Siri shortcuts.

Errors

WatchKitErrorCode

Error codes reported by WatchKit.

WatchKitErrorDomain

The domain for WatchKit errors. This value is used in the NSError class.

Property List Keys

Property List Key CLKComplicationPrincipalClass

The name of the class that implements the complication data source protocol.

Name: ClockKit Complication - Principal Class
Property List Key CLKComplicationSupportedFamilies

The complication families for which the app can provide data.

Name: ClockKit Complication - Supported Families
Property List Key PUICAutoLaunchAudioOptOut

A Boolean value indicating whether an audio app on Apple Watch automatically launches when its corresponding iOS app starts playing audio content.

Name: Opt out of Auto-launch Audio App (Watch)
Property List Key WKAppBundleIdentifier

A watchOS app's bundle ID.

Property List Key WKBackgroundModes

The execution time for a WatchKit extension while running in the background.

Name: Required background modes (Watch)
Property List Key WKCompanionAppBundleIdentifier

The bundle identifier for the iOS app that's paired with a watchOS app.

Property List Key WKExtensionDelegateClassName

The name of the class that's the delegate for the WKExtension object in a WatchKit extension.

Property List Key WKWatchKitApp

A Boolean value indicating whether the bundle is the watchOS app that the user launches.