界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
效率与协作 · SKILL.md

ios-app-lifecycle

ios-app-lifecycle

【效率与协作】Configure AppDelegate, SceneDelegate, deep linking, and background tasks. Use when configuring iOS app lifecycle, deep linking, or background task scheduling.

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: ios-app-lifecycle description: Configure AppDelegate, SceneDelegate, deep linking, and background tasks. Use when configuring iOS app lifecycle, deep linking, or background task scheduling. metadata: triggers: files: - 'AppDelegate.swift' - 'SceneDelegate.swift' keywords: - didFinishLaunchingWithOptions - willConnectTo - backgroundTask - Shortcut - UserActivity

iOS App Lifecycle

Priority: P0 (CRITICAL)

Implementation Workflow

  1. Configure SceneDelegate — Use for UI windows and scene-specific state in iOS 13+.
  2. Keep AppDelegate slim — Focus on app-wide setup (DI, Analytics, Push registration). Move initialization logic to dedicated Bootstrapper or AppCoordinator.
  3. Handle deep links — Prefer Universal Links over custom URL schemes. Handle via scene(_:continue:userActivity:). Route through Root Coordinator.
  4. Schedule background tasks — Use BGTaskScheduler for periodic data refresh. Always handle expirationHandler to avoid system kill.

See bootstrapper pattern and background task examples

Anti-Patterns

  • No Complex AppDelegate Logic: Delegate to Bootstrapper service
  • No Manual AppDelegate UIWindow: Use SceneDelegate for iOS 13+
  • No Sync Launch Network: Move all launch calls to background threads

References

我的收藏