Supporting iOS 27 app entity schemas and maintaining backwards compatability

We have an app that supports iOS 18+ We have a couple of AppEntity(s) that we are keen to make work with the new schemas along with several AppIntent(s).

We cannot increase our floor to iOS 27 for obvious reasons.

All the documentation suggests using the macros, e.g.

@AppEntity(schema: .audio.song)
struct SongEntity { ... }

This refuses to compile below iOS 26.

It's possible to add availability checks, e.g.

@available(anyAppleOS 27, *)
@AppEntity(schema: .audio.song)
struct SongEntity { ... }

But then the whole entity becomes unavailable on pre-27 OSes. So I tried moving the macro onto an extension, e.g.

struct SongEntity { ... }

@available(anyAppleOS 27, *)
@AppEntity(schema: .audio.song)
extension SongEntity { ... }

But this results in a compiler error:

'extension' macro cannot be attached to extension (extension of 'SongEntity')

One other option is to create a new entity with a totally different name and mark it as isAssistantOnly but this has a lot of quite negative downstream effects that make it unworkable. For example:

  • a lot of code duplication
  • duplication in search indexes if we index both sets of entities
  • awkwardness trying to use NSUserActivity when we have 2 different entity types
  • pain in downstream AppIntent arguments which would require duplicating every AppIntent which has more cascading effects

The same issues are present in AppIntent schemas too where even trying to add the most basic @AppIntent(schema: .system.open) to our existing OpenIntent doesn't seem possible for all the same reasons.

I am really struggling with how to structure code so we can support schemas, currently I don't really see a path forward here until our floor raises to iOS 27.

Is there a way to make this work nicely with the current APIs? What are others doing here? How can apps can ship in September and support both this and pre iOS 27 cleanly?

Thinking about solutions here, my ideal would be that the macros are improved to either:

  • be able to be applied to an extension rather than the structure itself.
  • expand in such a way that they still build the core AppEntity / AppIntent on pre 27 OSes but then add the iOS 27 schema additions behind @available internally so they can be used with older targets as essentially no-ops on the current definitions.

Thank you for your post and question. There is a very interesting part about supporting conditional extensions.

The second option is indeed only available for users running an OS version of 27 or higher. This ensures that users running an older OS version will not encounter this option.

Could you please clarify why you believe this option is not a suitable choice for you, considering that it is not available for users running an older OS version?

@available(anyAppleOS 27, *)
@AppEntity(schema: .audio.song)
struct SongEntity { ... }

You can add an else and provide an empty not available functionality but that will seem a bad choice, will be better to completely hide the functionality for users not having OS 27?

// Existing type, compiles fine down to pre OS 27 .
struct SongEntity: AppEntity {
}

I don’t think is possible to make a single AppEntity or AppIntent support both a newer schema and an older deployment target.

Looks like you already created a bug today at 7 am Cupertino time?

Albert  WWDR

This makes no sense to me at all "You can add an else and provide an empty not available functionality" - I'm not sure what you are suggesting here but I do not believe it is possible to have an else branch on an @available check.

@binaryalchemy In this case if doesn’t make sense to you I recommend working with the team you file a bug and communicating your preferences to them.

You can see the status of your feedback in Feedback Assistant. There, you can track if the report is still being investigated, has a potential identifiable fix, or has been resolved in another way. The status appears beside the label "Resolution." We're unable to share any updates on specific reports on the forums.

For more details on when you'll see updates to your report, please see What to expect after submission.

Albert  WWDR

Supporting iOS 27 app entity schemas and maintaining backwards compatability
 
 
Q