sberrevoets / SDCAlertView

The little alert that could
MIT License
1.86k stars 297 forks source link

Crash on iOS 15 #319

Closed jeromeboursier closed 3 years ago

jeromeboursier commented 3 years ago

Hello,

On iOS 15, there's a referenced crash happening on AlertVisualStyle.swift - Line 156 during the init phase. As per the code, it seem to be the force unwrapping on the keyWindow responsible for this crash.

I can open a PR to change the force unwrap to an optional value instead, but I fear it'll always fall in the else case.

What are your thoughts on that?

Thanks. Jérôme

sberrevoets commented 3 years ago

I haven't watched the session yet, but I did see something about the windows APIs changing, keyWindow being one of them. I'm guessing changing it to optional-chaining will just make it fail silently so we'll need to look at a different solution. I'm sure there's some migration strategy, just don't know what that is yet.

jeromeboursier commented 3 years ago

Hello Scott,

I took a closer look, and it turns out it crashes because an alert was trying to be presented before the keyWindow had a chance to unhide.

For everyone facing this kind of issue, please be sure you're not displaying a popup on an hidden window: make sure .makeKeyAndVisible() has been called beforehand.