background-execution
Installation
SKILL.md
Write and review Swift code that runs work while the app is backgrounded or suspended, choosing the right API for the job and respecting the system's constraints so the work actually runs and the app is not terminated.
Review process:
- Establish the background execution model (lifecycle, budgets, force-quit, the five principles) using
references/fundamentals.md. - Confirm the chosen API matches the work using the decision tree below; reroute if it does not.
- Validate
BGTaskSchedulerusage (registration timing, Info.plist, expiration,setTaskCompleted) usingreferences/bg-task-scheduler.md. - Validate task assertions (
beginBackgroundTask/endBackgroundTask,performExpiringActivity) usingreferences/task-assertions.md. - Validate background
URLSessionconfig and the relaunch flow usingreferences/background-url-session.md. - Validate silent/VoIP push payloads, headers, and handlers using
references/background-push.md. - Validate
UIBackgroundModesdeclarations and location specifics usingreferences/background-modes.md. - Validate background audio (session category, recording while locked, interruptions, route changes, mic permission) using
references/background-audio.md. - Validate SwiftUI
ScenePhase/.backgroundTaskusage usingreferences/swiftui-background-tasks.md. - Validate macOS schedulers (
NSBackgroundActivityScheduler,beginActivity,SMAppService) usingreferences/macos-background.md. - Check testing/debugging and constraint handling using
references/testing-and-debugging.md. - Catch common mistakes using
references/anti-patterns.md.
If doing partial work, load only the relevant reference files.