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

Generated Models Will fail to compile on Xcode 15 if you enable ExistentialAny compiler flag #3205

Closed
BrentMifsud opened this issue Aug 25, 2023 · 6 comments · Fixed by apollographql/apollo-ios-dev#379
Labels
bug Generally incorrect behavior medium-priority

Comments

@BrentMifsud
Copy link

BrentMifsud commented Aug 25, 2023

Summary

if you add the following flag to Other Swift Flags on Xcode 15, generated models will fail to compile:

-enable-upcoming-feature ExistentialAny

They all seem to be failing for the same reason(s):

  • Use of protocol 'ParentType' as a type must be written 'any ParentType'
  • Use of protocol 'Error' as a type must be written 'any Error'

Should add a codegen option to enable existential any for generated protocols. Or perhaps this should be the default, and a codegen config item should exist for older swift versions.

Version

1.3.0

Steps to reproduce the behavior

in your app build settings, add the following items to Other Swift Flags:

-enable-upcoming-feature
ExistentialAny

run code gen

try to compile app.

Logs

No response

Anything else?

Enabling compiler flags for upcoming swift 6 features was recently added in swift 5.8. More details here: https://github.com/apple/swift-evolution/blob/main/proposals/0362-piecemeal-future-features.md

Strangely enough, this issue SHOULD happen on Xcode 14.3 and up, but it only seems to happen on Xcode 15 beta.

@BrentMifsud BrentMifsud added bug Generally incorrect behavior needs investigation labels Aug 25, 2023
@AnthonyMDev
Copy link
Contributor

Thanks for bringing this to our attention.

We should just add the any keyword to all of these files. The existential any is going to become a requirement in Swift 6, it’s just suggested for now. We should get ahead of the game and add it.

In fact, we should actually just turn the -enable-upcoming-feature ExistentialAny flag on in our project settings and CI tests so that we catch any more of these we may introduce in the mean time.

@BrentMifsud
Copy link
Author

BrentMifsud commented Feb 25, 2024

@AnthonyMDev any updates on this?

Swift team just announced that swift 5.10 is the last swift 5.x.x release. And that the swift 6 release branch is being cut in march

So I suspect swift 6 will be launching with Xcode 16 in September.

@AnthonyMDev
Copy link
Contributor

We had made a mistake in our setup when we were trying to reproduce this before. Just took another look at it today, and I see the issue now. We've bumped up the priority on this, and we'll make sure to get this done before it officially launches in Xcode 16.

If you'd like to see it happen earlier than that, we would be happy to accept a PR from you to contribute the fixes. If you want to make a contribution, I'd be happy to chat with you about what parts of the code need changes in order to make a suitable PR for this.

@BrentMifsud
Copy link
Author

Great! Thanks for the update. I'm not in too much of a rush right now. I'm still in the process of making the rest of our codebase compliant with the other Swift 6 changes.

If this becomes a blocker in future I can try and take a crack at it.

@calvincestari
Copy link
Member

Adding a note here that it looks like ExistentialAny will not be in the Swift 6 release. This should be an easy enough change to make but since it was dropped from Swift 6 that may influence the priority assigned to this issue.

Copy link
Contributor

github-actions bot commented Jun 6, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Generally incorrect behavior medium-priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants