Framework

WatchKit

Build apps that leverage watchOS features like background tasks, extended runtime sessions, and access to the Digital Crown.

Overview

The WatchKit framework provides the infrastructure for creating watchOS apps.

An illustration showing an Apple Watch surrounded by icons representing the features handled by the WatchKit framework, including creating user interfaces, playing background audio, or displaying custom notifications.

All watchOS apps must have an extension delegate that you can use to respond to your app’s life cycle events. You can also use the delegate to manage background tasks, extended runtime sessions, Siri intents, workout sessions, or Handoff activity from other devices.

The WatchKit framework performs other support tasks, such as accessing device-specific information about the Apple Watch running your app, registering for remote notifications, and creating custom interfaces for local and remote notifications.

Topics

Essentials

Creating an Effective watchOS Experience

Develop a complete watch experience that emphasizes brief interactions and presents the right information at exactly the right time.

Creating Independent watchOS Apps

Set up a watchOS app that installs and runs without an iOS companion app.

Building watchOS App Interfaces with SwiftUI

Create your app’s user interface by programmatically composing single-responsibility views.

Creating a watchOS App with SwiftUI

Use common SwiftUI elements and watch-specific features in a comprehensive sample app.

App Infrastructure

Working with the watchOS App Life Cycle

Learn how the watchOS app life cycle operates and respond to life cycle notification methods.

Keeping Your watchOS Content Up to Date

Ensure that your watchOS content is relevant and up to date.

Authenticating Users on Apple Watch

Create an account sign-up and sign-in strategy for Apple Watch.

class WKExtension

An object that manages behaviors shared by an app’s interface controllers.

protocol WKExtensionDelegate

A collection of methods that manage the app-level behavior of a WatchKit extension.

class WKInterfaceDevice

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

Storyboard Support

Storyboard Elements

Connect your code to storyboard elements using interface controllers, interface objects, and event handlers.

Extended Runtime Sessions

Using Extended Runtime Sessions

Create an extended runtime session that continues running your app after the user stops interacting with it.

class WKExtendedRuntimeSession

A session that continues to run your app after the user has stopped interacting.

enum WKExtendedRuntimeSessionErrorCode

The error codes reported by extended runtime sessions.

let WKExtendedRuntimeSessionErrorDomain: String

The domain for errors reported by extended runtime sessions.

Background Tasks

Running watchOS Apps in the Background

Schedule and perform background tasks from within your app.

Playing Background Audio

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

Preparing to Take Your watchOS App’s Snapshot

Use snapshot background tasks to provide a timely, accurate snapshot of your app.

class WKRefreshBackgroundTask

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

class WKApplicationRefreshBackgroundTask

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

class WKURLSessionRefreshBackgroundTask

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

class WKWatchConnectivityRefreshBackgroundTask

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

class WKSnapshotRefreshBackgroundTask

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

class WKIntentDidRunRefreshBackgroundTask

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

class WKRelevantShortcutRefreshBackgroundTask

A background task used to periodically donate relevant Siri shortcuts.

Background Session Keys

Enable background sessions.

Notifications

Enhancing Your watchOS App with Notifications

Alert the user of significant events with notifications even when your app is not running.

Errors

struct WatchKitError

An error reported by WatchKit.