Conditional Compilation for Renamed Macro?

The @AssistantIntent macro from Apple’s AppIntents was renamed to @AppIntent in the iOS 26 SDK. While I work on fully adopting the iOS 26 SDK, I’d like to keep my project compiling (warning-free) with both versions.

I was hoping I could simply write…

#if compiler(>=6.2)
@AppIntent(schema: ...)
#else
@AssistantIntent(schema: ...)
#endif
struct ...

but this yields the following build error in Xcode 16:

AssistantSchemaIntent protocol is not available to adopt directly, instead use the 'AssistantIntent(schema:)' macro

Is there a way to write this without duplicating the entire struct?

For some reason, it works in both Xcode versions if I invert the condition:

#if compiler(<6.2)
@AssistantIntent(schema: ...)
#else
@AppIntent(schema: ...)
#endif
struct ...
4 Likes