Swift switch case and API availability

How to use #available(iOS 14, *) for a single switch case statement?

Our app currently supports iOS 12 and we want to use switch statement with @unknown default qualifier to get warnings in future if there's new cases

Here case .ephemeral is missing, thus getting a warning

Tried case .ephemeral where #available(iOS 14, *) but it seems incorrect

I probably miss your point. Problem is not adding .ephemeral, is it ?

You can always code like this:

     private func mark(_ status: UNAuthorizationStatus) -> Bool {
          if #available(iOS 14.0, *) {
               switch status {
                    case .authorized, .provisional: return true
                    case .denied, .notDetermined : fallthrough
                    case .ephemeral: return true
                    @unknown default: return false
               }
          } else {
               switch status {
                    case .authorized, .provisional: return true
                    case .denied, .notDetermined : fallthrough
                    @unknown default: return false
               }
          }
     }

or, of course

                    case .ephemeral:
                         if #available(iOS 14.0, *) {
                              return true
                         } else {
                              return false
                         }
Swift switch case and API availability
 
 
Q