realm-swift
realm-swift copied to clipboard
Xcode 15 Beta 8: New Non-Sendable Warning for Actor-Based Realm Init
How frequently does the bug occur?
Always
Description
Xcode 15 Beta 8 generates a new warning when you use Realm's suggested initialization pattern for an Actor-based realm:
actor MyActor
{
private var realm: Realm! // implicitly unwrapped so we can pass `self` to -Realm(actor:) within init.
init() {
realm = try await Realm(actor: self) // WARNING: Non-sendable type 'Realm' returned by implicitly asynchronous call to nonisolated function cannot cross actor boundary
}
}
Stacktrace & log output
N/A
Can you reproduce the bug?
Always.
NB: I have the strict concurrency checking
build option set to complete
. That may be necessary to see the warning.
Reproduction Steps
Create an actor-isolated Realm by following the pattern recommended in the documentation, as above.
Version
10.42.0
What Atlas Services are you using?
Local Database only
Are you using encryption?
No
Platform OS and version(s)
macOS 13.5.2
Build environment
Xcode version: Xcode 15 Beta 8 Dependency manager and version: SPM
Note: changing the import statement to @preconcurrency import RealmSwift
does remove this warning, but it's not clear that this is correct—RealmSwift does offer concurrency support via actors, etc.
don't you need to specify actor: in the init?
I have the same problem while using the example here: https://www.mongodb.com/docs/realm/sdk/swift/use-realm-with-actors/#define-a-custom-realm-actor