apollographql / apollo-ios

📱  A strongly-typed, caching GraphQL client for iOS, written in Swift.
https://www.apollographql.com/docs/ios/
MIT License
3.87k stars 717 forks source link

Apollo code-gen fails to compile on Xcode 15.3 with StrictConcurrency enabled #3348

Closed dfed closed 6 months ago

dfed commented 6 months ago

Summary

Apollo code-gen does not compile on Xcode 15.3 with concurrency checking set to Strict. static let properties fail to compile with the following error:

Static property 'XXXXX' is not concurrency-safe because it is not either conforming to 'Sendable' or isolated to a global actor; this is an error in Swift 6

Version

1.9.0

Steps to reproduce the behavior

Generate Swift with Apollo that generates a static OperationDocument, Interface, Object, or Union

Logs

No response

Anything else?

I was able to get things compiling in my own repo by writing the following extensions:

extension ApolloAPI.OperationDocument: @unchecked Sendable {
    // This type is immutable and its properties are also immutable.
}

extension ApolloAPI.Interface: @unchecked Sendable {
    // This type is immutable and its properties are also immutable.
}

extension ApolloAPI.Object: @unchecked Sendable {
    // This type is immutable and its properties are also immutable.
}

extension ApolloAPI.Union: @unchecked Sendable {
    // This type is immutable and its properties are also immutable.
}

Ideally these types would conform to either Sendable or @unchecked Sendable within the Apollo library. This work is likely related to #3291

AnthonyMDev commented 6 months ago

We're going to move #3291 from 2.0 back into 1.x and add it to our current roadmap. Closing this as duplicate. Thank you for the feedback and suggestion!

github-actions[bot] commented 6 months ago

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo iOS usage and allow us to serve you better.