Background execution audit

From cruisediary/apple-app-review-skills · View interactive version

Background execution audit is an AI agent skill from the GitHub repository cruisediary/apple-app-review-skills. Detects apps that abuse iOS background execution modes — particularly silent audio used to keep the app alive, location background mode used for non-navigation purposes, and background task implementations that do excessive work — enforcing Guideline 2.5.4.

How to use this skill

Skill file

Skill: Background Execution Audit

<!-- SEO: background mode silent audio location abuse BGTaskScheduler background fetch voip Guideline 2.5.4 iOS App Store rejection -->

Purpose

Detects apps that abuse iOS background execution modes — particularly silent audio used to keep the app alive, location background mode used for non-navigation purposes, and background task implementations that do excessive work — enforcing Guideline 2.5.4 which requires background modes to be used only for their intended purpose.

Apple Guideline

Real-World Rejection Cases

Source: Apple Developer Forums (multiple reports)

Root cause: Playing silent audio in the background solely to prevent app suspension is explicitly prohibited — it abuses the audio background mode, which is intended for apps that provide audible content to the user. Use BGTaskScheduler for background processing instead.

Source: Apple Developer Forums (Guideline 2.5.4 enforcement)

Root cause: Background location must be used only when the app's core functionality genuinely requires continuous location updates (navigation, geo-fencing). Using it as a workaround to run in the background for non-location tasks violates 2.5.4.

Source: Apple Developer Forums

Root cause: Each background mode has a specific intended use case — declaring a background mode for a purpose other than its design is treated as abuse. Use BGProcessingTask or BGAppRefreshTask for periodic background work.

Trigger

Invoke on any iOS/macOS project that declares background modes in Info.plist or uses BGTaskScheduler, CLLocationManager, or AVAudioSession.

Inputs

| Name | Type | Default | Description |

|------|------|---------|-------------|

| project_root | path | cwd | iOS/macOS project root |

| shared_context | object | nil | Pre-collected context from appstore-full-audit Phase 1 |

Actions

Phase 1: Context Collection

Skip this phase if shared_context is provided.

  1. Glob **/Info.plist — locate Info.plist for background mode declarations.
  2. Glob **/*.swift — collect all Swift source files.

Phase 2: Checks

  1. Background audio mode with silent/zero-volume session

Read Info.plist — check UIBackgroundModes for audio.

If audio is declared, Grep AVAudioSession|AVAudioPlayer in **/*.swift.

If audio session category is .ambient or .soloAmbient with no audible content, OR if volume is set to 0 near background mode activation → 🔴 CRITICAL. Silent audio background mode abuse.

  1. Background location declared — justify core use

Read Info.plist — check UIBackgroundModes for location.

If location is present, Grep CMPedometer|CMMotionActivityManager|CoreMotion in **/*.swift.

If the app uses CoreMotion/pedometer APIs while also declaring background location → 🟠 HIGH. Step counting and activity tracking belong in CoreMotion, not CoreLocation — background location should not be used as a substitute.

  1. VoIP background mode without calling functionality

Read Info.plist — check UIBackgroundModes for voip.

If voip is present, Grep CXProvider|CXCallController|CallKit|VoIP in **/*.swift.

If voip background mode declared but no CallKit integration found → 🔴 CRITICAL. VoIP background mode is reserved for apps providing telephone-like calling via CallKit — using it for persistent socket connections violates 2.5.4.

  1. BGTaskScheduler not registered for declared modes

Grep pattern BGTaskScheduler|BGProcessingTask|BGAppRefreshTask in **/*.swift.

If background modes fetch or processing are declared but BGTaskScheduler.shared.register is absent → 🟠 HIGH. Background fetch/processing tasks must be registered with BGTaskScheduler — unregistered tasks waste background time and will be deprecated.

  1. Location background mode with Always authorization

Grep pattern requestAlwaysAuthorization in **/*.swift.

If requestAlwaysAuthorization is called but background location mode is absent from Info.plist → 🟠 HIGH. Requesting Always authorization without declaring background location mode causes the OS to silently downgrade to WhenInUse.

Phase 3: Output

Collect all findings from Phase 2 and build the prioritised findings list below. Include file paths and line numbers. Omit tiers with no findings.

Output Format

## Background Execution Audit — Findings

### 🔴 CRITICAL — Guaranteed rejection
- [ ] TODO: Remove silent audio background mode — playing inaudible audio to prevent suspension violates 2.5.4; use BGTaskScheduler for background work — `AudioKeepAlive.swift:12` — Guideline 2.5.4
- [ ] TODO: Remove voip background mode or integrate CallKit — voip mode requires telephone-like calling functionality via CXProvider — `Info.plist` — Guideline 2.5.4

### 🟠 HIGH — Very likely rejection
- [ ] TODO: Replace CoreLocation-based step counting with CMPedometer — background location is not required for pedometry — `StepTracker.swift:34` — Guideline 2.5.4
- [ ] TODO: Register BGProcessingTask in BGTaskScheduler — background-processing mode declared but BGTaskScheduler not configured — `AppDelegate.swift` — Guideline 2.5.4

### 🟡 MEDIUM — Possible rejection
- [ ] TODO: Review all declared UIBackgroundModes against actual usage — remove any mode not actively used by a core feature

### 🟢 LOW — Best practice
- [ ] TODO: Add a comment next to each UIBackgroundMode entry explaining which feature requires it — helps reviewers and future maintainers understand the justification

Tools Used

Glob, Grep, Read

Constraints

Quick Commands

# Check declared background modes
!plutil -convert json -o - Info.plist 2>/dev/null | python3 -c "import sys,json; d=json.load(sys.stdin); print('Background modes:', d.get('UIBackgroundModes', 'none'))"

# Check for silent audio pattern
!grep -rn "AVAudioSession\|AVAudioPlayer" . --include="*.swift" -A5 | grep -i "ambient\|volume.*0\|setVolume(0"

# Check for BGTaskScheduler usage
!grep -rn "BGTaskScheduler\|BGProcessingTask\|BGAppRefreshTask" . --include="*.swift"

# Check for voip + CallKit
!grep -rn "CXProvider\|CXCallController\|CallKit" . --include="*.swift" | wc -l

Swift Anti-Pattern Reference

examples/swift/BackgroundExecutionPatterns.swift

Detection Steps

  1. Find target files
  1. Search for rejection patterns
  1. Determine verdict
  1. Report
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.