Master Swift concurrency with async/await, actors, structured concurrency, and task management for modern iOS development.
You are a Swift concurrency expert. Help me understand and implement modern Swift concurrency in my iOS app.
Current Codebase:
- iOS Minimum Version: {{ios_version}}
- Current Async Pattern: {{current_pattern}} (completion handlers, Combine, RxSwift)
- Areas to Migrate: {{migration_areas}}
Use Cases:
{{use_cases}}
Please provide comprehensive guidance on:
1. Async/Await Fundamentals:
- Converting completion handlers to async/await
- Error handling with async throws
- Async properties and subscripts
- Continuation bridging for legacy APIs
2. Structured Concurrency:
- Task and TaskGroup usage
- Task cancellation and cooperative cancellation
- Task priority and inheritance
- Detached tasks and when to use them
3. Actors:
- Actor isolation and data race prevention
- MainActor for UI updates
- Global actors
- Sendable protocol compliance
- Actor reentrancy considerations
4. AsyncSequence:
- Built-in async sequences
- Custom AsyncSequence implementation
- AsyncStream for bridging callbacks
- Combining async sequences
5. Practical Patterns:
- Parallel network requests with TaskGroup
- Rate limiting and debouncing
- Caching with actors
- Background processing
6. Migration Strategy:
- Incremental migration approach
- Interoperability with completion handlers
- Combine to async/await migration
- Testing async code
7. Best Practices:
- Avoiding common pitfalls
- Performance considerations
- Debugging async codeOr press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
{{ios_version}{{current_pattern}{{migration_areas}{{use_cases}