Swift Concurrency Modernization and Actor Isolation Plan
Plan a structured migration from legacy callbacks and locks to Swift structured concurrency and actor isolation.
Use this template when planning a phased refactor of legacy asynchronous Swift or Objective-C code into async/await, Tasks, and Actors. It creates an actionable, risk-managed roadmap for enabling strict concurrency checking across modules.
Role: Principal Swift Systems Architect specializing in language runtime safety and modern multithreading architecture.
Context
- Target Subsystem: {{target_subsystem}}
- Existing Asynchronous Patterns: {{legacy_asynchronous_patterns}}
- Target Swift Concurrency Level: {{swift_concurrency_mode}}
- Minimum Supported OS Deployment Target: {{minimum_os_target}}
- Thread-Critical Dependencies: {{third_party_dependencies}}
- Critical Codebase Size / Module Count: {{module_scope_size}}
Task
Develop a comprehensive architectural migration plan to transition {{target_subsystem}} from {{legacy_asynchronous_patterns}} to modern Swift structured concurrency under {{swift_concurrency_mode}} without introducing regressions, data races, or UI stutter on {{minimum_os_target}}.
Method
- Audit the dependency graph of {{target_subsystem}} across {{module_scope_size}} to identify leaf nodes and isolate non-Sendable types.
- Classify shared mutable state across components and determine boundaries for
@MainActor, custom global actors, and isolatedactortypes. - Map current completion-handler APIs, Combine pipelines, and DispatchQueues in {{legacy_asynchronous_patterns}} to equivalent
async/awaitandAsyncSequencecontracts. - Design compatibility shims using
@preconcurrencyand continuation bridges to support un-migrated code in {{third_party_dependencies}}. - Sequence the migration into phased pull requests, starting with leaf domain models before refactoring view models and coordinator layers.
- Establish runtime validation workflows leveraging Xcode Thread Sanitizer (TSan) and concurrency runtime diagnostics.
- Formulate a fallback and regression rollback protocol targeting specific subsystem cutovers.
Constraints
- MUST eliminate all compiler warnings generated by {{swift_concurrency_mode}}.
- MUST NOT introduce priority inversion or deadlocks caused by unconstrained Task instantiation.
- Plan MUST maintain backward runtime compatibility with {{minimum_os_target}}.
- Keep implementation guidance strictly tailored to Swift native concurrency primitives.
Output format
Provide a structured migration plan divided into:
- Architecture & Model Sendability Strategy (bulleted type classifications)
- Phased Rollout Sequence (numbered phases with entry/exit criteria)
- Dependency & Compatibility Bridge Plan (table format with component, approach, risk)
- Verification & Testing Matrix (test type, tooling, pass condition) Total length must be between 400 and 800 words.
Self-review
- Did I define clear Actor isolation boundaries for all shared mutable state?
- Are all listed steps compliant with the constraints of {{minimum_os_target}}?
- Does the plan isolate high-risk third-party calls using
@preconcurrencyor continuations?
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.