firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.55k stars 1.45k forks source link

Make @DocumentID property wrapper conform to the Sendable Protocol #8374

Open AlTensor opened 3 years ago

AlTensor commented 3 years ago

The @DocumentID property wrapper for Firestore does not conform to the concurrency protocol Sendable in the upcoming Swift 5.5. Conformance to Sendable will be very important for types that need to be used with Actors. This document provides more details: https://github.com/apple/swift-evolution/blob/main/proposals/0302-concurrent-value-and-concurrent-closures.md

We can override the compiler with @unchecked annotation on the type but I'm hesitant to do that without a confirmation that @DocumentID can in fact be safely Sendable

google-oss-bot commented 3 years ago

I found a few problems with this issue:

schmidt-sebastian commented 3 years ago

As far as I can tell,@DocumentID does not currently conform to the requirements of @Sendable as it contains mutable state. We can address this shortly.

edonv commented 1 year ago

Any updates on this being added?

mesqueeb commented 1 month ago

@wu-hui friendly bump : ) Btw, I was wondering, are there plans to rewrite Firebase Swift SDK in the Swift language?

wu-hui commented 1 month ago

Thanks for the reminder. Unfortunately we have not found time for this, and still do not know when we can get to this.

edonv commented 1 month ago

Can't this at least be partially completed for String-based @DocumentIDs? I could be wrong (I don't have a project up to test this out), but couldn't you add something like this to the DocumentID file?

public extension DocumentID: Sendable where Value == String {}

I know it's more involved to add Sendable conformance to DocumentReference, but when @DocumentID is just wrapping the document ID String, Sendable conformance shouldn't be too involved.