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

Xcode 13 issue - Enum cases with associated values cannot be marked potentially unavailable with '@available' #471

Closed
rizwan95 opened this issue Jun 8, 2021 · 28 comments · Fixed by #478

Comments

@rizwan95
Copy link

rizwan95 commented Jun 8, 2021

When we try to build SwiftMessages with Xcode 13 beta, the following error is being thrown: Enum cases with associated values cannot be marked potentially unavailable with '@available'
Screenshot 2021-06-08 at 12 01 40 PM

@rizwan95 rizwan95 changed the title Enum cases with associated values cannot be marked potentially unavailable with '@available' Xcode 13 issue - Enum cases with associated values cannot be marked potentially unavailable with '@available' Jun 8, 2021
@dneykov
Copy link

dneykov commented Jun 8, 2021

Seems like a bug in Swift 5.5

https://bugs.swift.org/browse/SR-14539

@wtmoose
Copy link
Member

wtmoose commented Jun 8, 2021

I'll keep an eye on this. Hopefully, they'll fix the bug!

@rizwan95
Copy link
Author

rizwan95 commented Jun 9, 2021

@wtmoose @dneykov There is no activity in the bug report after it was reported or am I missing anything??

@racsol
Copy link

racsol commented Jun 15, 2021

Hi, do you have any hopes for the bug to be fixed by apple before iOS 15 release? the bug SR-14539 is marked as "Improvement" and without any activity for a long time...

@wtmoose
Copy link
Member

wtmoose commented Jun 15, 2021

@racsol I have no idea

@rizwan95
Copy link
Author

My intuition says that Apple won't fix the bug sooner. What do we do?

@ymkim50
Copy link

ymkim50 commented Jun 19, 2021

I temporarily downloaded the source.
And set Platform in Package.swift

platforms: [
.iOS ("13.0")
],

And added it as a Local Package. After that, no error occurred.

This is a temporary method.

@rizwan95
Copy link
Author

I temporarily downloaded the source.
And set Platform in Package.swift

platforms: [
.iOS ("13.0")
],

And added it as a Local Package. After that, no error occurred.

This is a temporary method.

Yes that is one hackish solution...

@eigenl
Copy link

eigenl commented Jun 29, 2021

Asked the author of that change about it:
https://twitter.com/slava_pestov/status/1409910935347732489?s=20

In short, the code needs to be updated not to require @available

edit: deleted brainfart

@wtmoose
Copy link
Member

wtmoose commented Jun 29, 2021

LOL...I'm not sure his suggestion would qualify as a workaround.

@wtmoose
Copy link
Member

wtmoose commented Jun 29, 2021

@eigenl It seems you're trying to suggest a compile-time check but available is a run time thing. The code you're written if #available...#else isn't valid syntax and wouldn't compile.

If they're actually not going to fix this, then the only options I see are (a) make a breaking API change in SwiftUI or (b) stop supporting iOS 12 and below.

I'm inclined to take option (b).

@eigenl
Copy link

eigenl commented Jun 29, 2021

Yeah, sorry for the brainfart. Removed it. Another passable solution would be

case windowScene(_: Any, windowLevel: UIWindow.Level)

and casting the associated value to UIWindowScene where needed (just one location in SwiftMessages.Config+Extensions.swift).

This does remove compile-time guarantee but requires no changes to applications and is the smallest change that could be made to fix it I believe. Dropping iOS 12 is certainly an option, but poses a problem for application developers where decisions regarding minimum targets are out of their hands.

@rizwan95
Copy link
Author

rizwan95 commented Jun 30, 2021

I suppose the solution proposed by @eigenl should be good enough. What are your thoughts @wtmoose ? We need to act quick or else there will be many projects breaking due to this issue

@gereons
Copy link

gereons commented Jul 7, 2021

I reported the same issue in https://bugs.swift.org/browse/SR-14878 and that was just closed as "works as designed". Bummer.

@racsol
Copy link

racsol commented Jul 8, 2021

Any plans on fixing this issue? It seems that this will not be fixed in the swift project....

@rizwan95
Copy link
Author

Yeah, sorry for the brainfart. Removed it. Another passable solution would be

case windowScene(_: Any, windowLevel: UIWindow.Level)

and casting the associated value to UIWindowScene where needed (just one location in SwiftMessages.Config+Extensions.swift).

This does remove compile-time guarantee but requires no changes to applications and is the smallest change that could be made to fix it I believe. Dropping iOS 12 is certainly an option, but poses a problem for application developers where decisions regarding minimum targets are out of their hands.

Can we go with this solution? This seems to be optimal. @wtmoose

@wtmoose
Copy link
Member

wtmoose commented Jul 14, 2021

A quick fix using case windowScene(_: Any, windowLevel: UIWindow.Level) is on branch work/9.0.4 for folks to try.

Version 10 will revert back to case windowScene(_: UIWindowScene, windowLevel: UIWindow.Level) and instead require iOS 13.

@acrabb
Copy link

acrabb commented Aug 17, 2021

Any update on this?

@mzhangFE
Copy link

We tried the latest version and still saw the same issue. The quick fix mentioned by @wtmoose worked. I may have missed something here but why could you make that as the official fix? Also some apps still support iOS 12 so dropping iOS 12 is not desired.

@giginet
Copy link
Contributor

giginet commented Sep 12, 2021

I submitted PR to solve this issue. Please check it out!

#478

@rizwan95
Copy link
Author

Looks like the issue is solved with Xcode 13 RC.

@wtmoose
Copy link
Member

wtmoose commented Sep 15, 2021

Woah, nice! I'll take a look when I get a chance to install the new build

@timonchev
Copy link

@rizwan95 same issues in Xcode 13 RC too

@bogartpi
Copy link

Any update on fixing this issue?

@racsol
Copy link

racsol commented Sep 17, 2021

@bogartpi the issue is fixed on branch 9.0.4. Does anyone know the released date of 9.0.4?

@Aidar
Copy link

Aidar commented Sep 17, 2021

Please, release fix. We really need it. That is our single library that can't be build in Xcode 13.

@wtmoose
Copy link
Member

wtmoose commented Sep 17, 2021

@rizwan95 9.0.4 released. Thanks!

@wtmoose wtmoose closed this as completed Sep 17, 2021
@rizwan95
Copy link
Author

Thanks a lot @wtmoose!

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

Successfully merging a pull request may close this issue.