TipUIPopoverViewController can be referenced below iOS 17 without a compiler error and it shouldn't

We have found a runtime crash using TipUIPopoverViewController because Xcode didn't warn about its usage when using a deployment target of iOS 16, without a proper #if available verification.

In Xcode Version 16.2 (16C5032a), using swift code, TipUIPopoverViewController can be used without if #available(iOS 17, *) without even trigger a warning or compiler error.

This is the snippet we're using in a UIViewController, and it compiles without a warning.

@objc
private func myMethod() {
    if presentedViewController is TipUIPopoverViewController {
        // do something
    }
}

Of course this triggers a runtime error, specifically, a EXC_BAD_ACCESS.

I was expecting that the same way Xcode warns us when we're using Tips and Tips.Status with iOS 16, this would also trigger a compilation error.

Answered by Frameworks Engineer in 822198022

Could you file a Feedback through Feedback Assistant?

Thank you for flagging this!

Accepted Answer

Could you file a Feedback through Feedback Assistant?

Thank you for flagging this!

I do have a workaround for you, although it is not ideal. If you try and cast the presentedViewController using as? it should bring back the availability error.

@objc
private func myMethod() {
    if let _ = presentedViewController as? TipUIPopoverViewController {
        // do something
    }
}

// Or
@objc
private func myMethod() {
    if presentedViewController as? TipUIPopoverViewController != nil {
        // do something
    }
}

We are working to get the is check fixed.

Thank you again for the feedback!

TipUIPopoverViewController can be referenced below iOS 17 without a compiler error and it shouldn't
 
 
Q