[Firestore] Label '@MainActor' isolated APIs of 'FirestoreQuery' #14163
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses the following errors in Swift 6 mode:
The issue is that
firestoreQueryObservable
is decorated with@StateObject
which is labeled@MainActor
in Xcode 16.1:So the property is isolated to the main actor and cannot be referenced from a non-main-actor-isolated context.
Backwards compatibility
I found that adding
@MainActor
causes a warning in Xcode 16+ for cases where@FirestoreQuery
is used inside a non-isolated class. The warning is not ideal (and a little unexpected, see https://www.jessesquires.com/blog/2024/06/05/swift-concurrency-non-sendable-closures/), but I think it's unlikely developers will face them as the@FirestoreQuery
is likely going to be used in a SwiftUI view which has the correct@MainActor
isolation by default.For Xcode 15, this PR doesn't seem to make a difference in behavior.
#no-changelog