用途:在将代码迁移到 Swift 6 时,处理编译期并发错误与警告,例如 Sendable 一致性、actor 隔离、全局变量非并发安全、非 Sendable 类型传参、@preconcurrency 导入、Task/async-await 与 GCD/DispatchQueue 迁移等。
主要能力:内置 Apple 完整迁移指南(25 个文件、3700+ 行),要求对每个错误先检索 migration-guide.md 再实施修复。提供按错误类型对应的检索命令,例如 grep -n -A 30 "Unsafe Global" migration-guide.md、grep -n -A 30 "Sendable Types" migration-guide.md、grep -n -A 30 "actor-isolated" migration-guide.md 等,并给出快速参考方向(如可变全局变量改用 let、@MainActor 或 actor)。
使用方式:先启用 -strict-concurrency=complete 警告,再逐个错误检索指南、阅读匹配章节、应用文档化修复并验证。构建命令:swift build -Xswiftc -strict-concurrency=complete;Swift 6 模式:swift build -Xswiftc -swift-version -Xswiftc 6。Package.swift 可设置 swiftSettings: [.enableExperimentalFeature("StrictConcurrency")] 或 swiftLanguageVersions: [.v6]。
适用场景:Swift 6 迁移、并发安全检查、actor 隔离与 Sendable 相关编译问题排查。
限制:强调必须检索指南后再修复,避免滥用 @unchecked Sendable 或 nonisolated(unsafe);修复后需测试运行时行为,执行顺序可能变化。具体平台与版本要求暂未提供。