Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error: Non-sendable type 'Realm' returned by implicitly asynchronous call to nonisolated function cannot cross actor boundary with Swift6 #8743

Open
qihuijia opened this issue Feb 13, 2025 · 0 comments

Comments

@qihuijia
Copy link

How frequently does the bug occur?

Always

Description

I just follow use-realm-with-actors document, and add this code in Xcode 16.1, Swift 6 in my package.

actor RealmActor {
    // An implicitly-unwrapped optional is used here to let us pass `self` to
    // `Realm(actor:)` within `init`
    var realm: Realm!
    init() async throws {
        realm = try await Realm(actor: self)
    }
}

and then there is a error: Non-sendable type 'Realm' returned by implicitly asynchronous call to nonisolated function cannot cross actor boundary.

And my package settings is like this:

// swift-tools-version: 6.0

import PackageDescription

let package = Package(
    name: "XXX",
    platforms: [
        .iOS(.v18)
    ],
    ...
    targets: [
            .target(
                name: "XXX",
                dependencies: [
                    .product(name: "RealmSwift", package: "realm-swift")
                ],
                swiftSettings: [
                    .swiftLanguageMode(.v6)
                ]
            ),
            .testTarget(
                name: "XXXTests",
                dependencies: ["XXX"]
            )
        ]

Stacktrace & log output

no. this is the compile error.

Can you reproduce the bug?

Always

Reproduction Steps

No response

Version

20.0.1

What Atlas Services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

iOS 18.0

Build environment

Xcode version: 16.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant