Swift: using new iOS16-only API as a property

Hi, I want to work with some of the new iOS16 APIs while maintaining backward compatibility with iOS15 as well as Xcode 13. I'm running into a problem here that I can't seem to store the new iOS16 API as a property of an existing class.

For e.g. I'm interested in using the new DataScannerViewController and want to store it as a property so I can reference it when scanning. If I declare it in my ViewController:

var dataScanner: DataScannerViewController?

it won't compile with Xcode13. I can't seem to also mark this with @available or #available(iOS 16) either:

if #available(iOS 16, *) {
        var dataScanner: DataScannerViewController?
}

What's the best way to handle this? In Objective-C, we could use __IPHONE_OS_VERSION_MIN_REQUIRED or something to that effect to avoid this problem, but I'm not sure what the best Swift solution is.

Swift: using new iOS16-only API as a property
 
 
Q