I am writing a new app from scratch using swift6 and SwiftData, and so far have been pretty happy not to run into errors or warnings about unsafe code.
Today I started to add Schema versioning to my SwiftData model and was surprised to get told by the compiler that MigrationStage and Schema.Version are not Sendable. This was simply on the standard (as per documentation examples) declarations, and not related to any concurrent use of the types or instances. As a fix it was suggesting making the import SwiftData @preconcurrency, which seemed to be a rather odd recommendation, akin to sweeping the problem under the carpet.
A Google turned up a June'24 post (see below) on the Apple Discussions forum, where a DTS engineer suggested that the error was spurious, and there should be no reason these types should not be Sendable. Their suggestion to solve the problem was that one should add:
extension MigrationStage: @unchecked @retroactive Sendable { }
extension Schema.Version: @unchecked @retroactive Sendable { }
The suggestion works, but my question is, is that an acceptable solution to this issue, or could it lead to future problems ?
If it is a canonical solution, I wonder why if DTS knew this in June, why isn't it already incorporated in iOS18/macOS15 ?
Cheers
Guy