home / skills / hoangnguyen0403 / agent-skills-standard / app-lifecycle
This skill guides iOS app lifecycle best practices, promoting lean AppDelegate usage, SceneDelegate coordination, and robust deep linking and background task
npx playbooks add skill hoangnguyen0403/agent-skills-standard --skill app-lifecycleReview the files below or copy the command above to add this skill to your agents.
---
name: iOS App Lifecycle
description: Standards for AppDelegate, SceneDelegate, Deep Linking, and Background Tasks.
metadata:
labels: [ios, lifecycle, scenedelegate, background-tasks]
triggers:
files: ['AppDelegate.swift', 'SceneDelegate.swift']
keywords:
[
didFinishLaunchingWithOptions,
willConnectTo,
backgroundTask,
Shortcut,
UserActivity,
]
---
# iOS App Lifecycle Standards
## **Priority: P0**
## Implementation Guidelines
### App & Scene Delegate
- **SceneDelegate**: Use for UI windows and scene-specific state in iOS 13+.
- **AppDelegate**: Focus on app-wide setup (DI, Analytics, Push notification registration).
- **Slim Delegates**: Move initialization logic to dedicated `Bootstrapper` or `AppCoordinator`.
### Deep Linking
- **Universal Links**: Prefer over custom URL schemes. Handle via `scene(_:continue:userActivity:)`.
- **Handling logic**: Routing should be handled by the Root Coordinator to navigate to specific screens.
### Background Tasks
- **Background Fetch**: Use `BGTaskScheduler` for periodically refreshing data.
- **Expiration**: Handle `expirationHandler` to avoid app kill by the system.
## Anti-Patterns
- **Fat AppDelegate**: `**No complex logic in didFinishLaunching**: Use a Bootstrapper service.`
- **Direct UI in AppDelegate**: `**No UIWindow setup in AppDelegate**: Use SceneDelegate for iOS 13+.`
- **Blocking Launch**: `**No synchronous network calls in launch**: Move to background thread or defer.`
## References
- [Lifecycle & Background Tasks](references/implementation.md)
This skill defines iOS app lifecycle standards for AppDelegate, SceneDelegate, deep linking, and background tasks. It codifies where to place initialization, routing, and background work so agents produce consistent, maintainable iOS code. The guidance targets iOS 13+ with scene support and modern background APIs.
The skill inspects app entry points and recommends moving heavy initialization out of AppDelegate into a Bootstrapper or AppCoordinator. It enforces SceneDelegate for window and UI state, Universal Links for deep linking, and BGTaskScheduler for periodic background work. It also flags anti-patterns like synchronous network calls or direct UI setup in AppDelegate.
Should I always use SceneDelegate?
For iOS 13 and later, prefer SceneDelegate for per-window UI and scene state. If supporting only iOS 12 or earlier, handle UI in AppDelegate, but aim to migrate when dropping legacy OS targets.
When are Universal Links not feasible?
Use Universal Links when possible. Custom URL schemes may be needed for legacy integrations or when Apple App Site Association cannot be configured, but they are less secure and less seamless.