I've just tried to update a project that uses SwiftData to Swift 6 using Xcode 16 beta 1, and it's not working due to missing Sendable conformance on a couple of types (MigrationStage
and Schema.Version
):
struct LocationsMigrationPlan: SchemaMigrationPlan {
static let schemas: [VersionedSchema.Type] = [LocationsVersionedSchema.self]
static let stages: [MigrationStage] = []
}
struct LocationsVersionedSchema: VersionedSchema {
static let models: [any PersistentModel.Type] = [
Location.self
]
static let versionIdentifier = Schema.Version(1, 0, 0)
}
This code results in the following errors:
error: static property 'stages' is not concurrency-safe because non-'Sendable' type '[MigrationStage]' may have shared mutable state
static let stages: [MigrationStage] = []
^
error: static property 'versionIdentifier' is not concurrency-safe because non-'Sendable' type 'Schema.Version' may have shared mutable state
static let versionIdentifier = Schema.Version(1, 0, 0)
^
Am I missing something, or is this a bug in the current seed? I've filed this as FB13862584.
Thanks for filing the feedback report. As of today, SwiftData does't run through Swift 6 check yet. I personally don't see any reason that MigrationStage
and Schema.Version
can't be sendable. You can probably consider using the following extensions to eliminate the warnings or errors related to Sensibility of the two types:
extension MigrationStage: @unchecked @retroactive Sendable { }
extension Schema.Version: @unchecked @retroactive Sendable { }
Best,
——
Ziqiao Chen
Worldwide Developer Relations.