Swift Concurrency Adoption and Migration Plan
Architect a structured, phased migration roadmap from legacy Grand Central Dispatch codebases to modern Swift Concurrency.
Use this template when planning the architectural modernization of an iOS codebase migrating from completion handlers and locks to async/await and actors. It helps engineering leads mitigate data race risks and establish incremental deployment milestones.
Role: Staff iOS Systems Architect specializing in Swift Concurrency runtime internals and legacy codebase modernizations.
Context
- Target application: {{app_name}}
- Deployment target: iOS {{target_ios_version}}
- Legacy concurrency patterns in use: {{legacy_concurrency_patterns}}
- High-risk business subsystems: {{critical_subsystems}}
- Compiler strict concurrency level target: {{strict_concurrency_level}}
Task
Generate a comprehensive, phased technical migration plan to transition {{app_name}} from {{legacy_concurrency_patterns}} to modern Swift structured concurrency, resolving data races across {{critical_subsystems}} while targeting {{strict_concurrency_level}} compliance on iOS {{target_ios_version}}.
Method
- Analyze the existing codebase boundaries in {{critical_subsystems}} to isolate completion-handler-driven APIs and thread-locking primitives.
- Establish an architectural baseline identifying Sendable protocol violations and shared mutable state.
- Design a bottom-up refactoring sequence prioritizing data access layers before UI coordinator bindings.
- Define custom global actors or isolated actor types to encapsulate mutable state in {{critical_subsystems}}.
- Specify bridging mechanisms using
withCheckedThrowingContinuationto modernize {{legacy_concurrency_patterns}} safely. - Formulate compiler diagnostic flags roadmap to advance progressively to {{strict_concurrency_level}}.
- Detail regression testing protocols, thread sanitizer (TSan) execution, and performance benchmarking for context-switch overhead.
Constraints
- MUST prioritize zero regression on main-thread responsiveness across all migrated paths.
- MUST NOT recommend unilateral rewrite approaches; migrations must remain backward-compatible across phases.
- MUST include explicit fallback handling for legacy completion callbacks during migration phases.
- All actor boundaries must be explicitly declared and justified.
Output format
Provide a technical plan structured into four mandatory sections:
- Architectural Gap Analysis (max 250 words)
- Phased Migration Schedule (3 phased milestones with entry/exit criteria)
- Critical Path Actor Design (code patterns and isolation boundaries)
- Thread Safety & Validation Protocol (TSan and regression steps, max 200 words)
Self-review
- Ensure every variable from context ({{app_name}}, {{target_ios_version}}, {{legacy_concurrency_patterns}}, {{critical_subsystems}}, {{strict_concurrency_level}}) is specifically addressed.
- Confirm that exactly 4 named output sections are produced.
- Verify all migration steps maintain binary stability and do not block the main runloop.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.