# background-processing

Sets up iOS background execution using BGTaskScheduler, URLSession, and push triggers. Useful when you need feed updates or nightly database maintenance.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 3900 installs · ★ 1237
- Author: dpearson2699
- License: LicenseRef-Unknown · policy=link-only · description only; the file stays with the author
- Source: https://github.com/dpearson2699/swift-ios-skills/tree/HEAD/skills/background-processing/SKILL.md
- Updated: 2026-07-31
- HTML: https://affpapa.org/en/nevibecode/skills/background-processing

## What it does

This skill guides background execution setup for Swift projects. It provides patterns for short-lived `BGAppRefreshTask` calls and heavy maintenance jobs via `BGProcessingTask`. You also get workflows for foreground-initiated work continuing offscreen through `BGContinuedProcessingTask` on iOS 26+.

Task handlers require early setup. You must register them with `BGTaskScheduler` before app launch finishes, either in `App.init()` for SwiftUI or `didFinishLaunchingWithOptions` for UIKit. Omitting an identifier from `BGTaskSchedulerPermittedIdentifiers` inside `Info.plist` causes `submit(_:)` to fail with `notPermitted`.

System time limits require defensive code. The skill includes patterns for assigning `expirationHandler` to cancel ongoing Swift tasks cleanly. That keeps the operating system from terminating the process abruptly.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill background-processing -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/background-processing/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/background-processing/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill background-processing -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/background-processing/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill background-processing -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/background-processing/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install dpearson2699/swift-ios-skills background-processing
```

2. **Manually: put the files in place**
- File: `.github/skills/background-processing/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill background-processing -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/dpearson2699/swift-ios-skills --path skills/background-processing
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/background-processing/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill background-processing -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/dpearson2699/swift-ios-skills/tree/HEAD/skills/background-processing/SKILL.md

## When to use it
- configure `BGTaskSchedulerPermittedIdentifiers` in `Info.plist`
- register background task handlers during SwiftUI app startup
- implement `expirationHandler` to stop running async operations
- schedule maintenance tasks requiring external power with `BGProcessingTask`

## Example prompts
- Configure a `BGAppRefreshTask` to refresh our feed in a SwiftUI app
- Show how to set up `BGProcessingTask` for database cleanup when plugged into power
- Check our `Info.plist` for the necessary background task identifiers and background modes

## Similar
- [vercel-react-native-skills](https://affpapa.org/en/nevibecode/skills/vercel-react-native-skills.md) — skill · 255200 installs
- [animate-expo](https://affpapa.org/en/nevibecode/skills/animate-expo.md) — skill · 137900 installs
- [mobile-native](https://affpapa.org/en/nevibecode/skills/mobile-native.md) — skill · 86600 installs
- [aso](https://affpapa.org/en/nevibecode/skills/aso.md) — skill · 75400 installs
- [swiftui-pro](https://affpapa.org/en/nevibecode/skills/swiftui-pro.md) — skill · 35200 installs
- [orca-emulator](https://affpapa.org/en/nevibecode/skills/orca-emulator.md) — skill · 5800 installs

From the same set: [dpearson2699/swift-ios-skills](https://affpapa.org/en/nevibecode/by/dpearson2699/swift-ios-skills.md) — 86 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
