Support new Siri AI APIs while keeping backwards compatibility

We are modernizing out in Intents and Entities to be ready for SiriAI. We would like to add more metdata (description & visibility) to our @Property annotations and use @ComputedProberty and DeferredProperty in some cases. But all of these APIs are only available on iOS 27 or even 27.x.

How would one use modern APIs to provide Siri AI with rich data while keeping backwards compatibility to iOS 17/18

Does the standard if #available help?

if #available(iOS 27.0, *) {
    // Use iOS 27+ API
} else {
    // Fallback for older iOS versions
}

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

No, it does not. This only helps for runtime checkes, not for compiletime proberty wrappers.

There may be a better way, but this implementation cuts down on duplicate code while still supporting versions prior to macOS 27.3

import AppIntents

protocol RollProtocol: AppIntent {}

extension RollProtocol {
    func perform() async throws -> some IntentResult {
        return .result(value: "Test123")
    }
}

struct RollIntent: RollProtocol {
    // compatibility implementation
}

@available(macOS 27.3, *)
@AppIntent(.tool)
struct RollTool: RollProtocol {
    // Tool specific implementation
}