19.9 · Dependencies, entities and queries, errors, and build-time metadata

App Intents look like ordinary Swift, but the system creates and discovers them, which changes how you inject dependencies, test them and ship them.

Mental model. An intent is a value the system instantiates: no initializer arguments, discovery at build time, and dependencies it resolves for you.

Running and testing

Dependencies and direct calls.

  1. How do App Intents get their dependencies, and why does @Dependency crash in a unit test? 19.9.1 · L5
    The system builds an intent with its zero-argument init, so a store or service cannot be passed in. @Dependency declares what the intent needs, and the app…
  2. How do AppEnum, AppEntity and EntityQuery work together, and how do parameter errors behave? 19.9.2 · L5
    An AppEnum is a fixed set of choices with a display name per case; an AppEntity is a user-visible object with a stable id, a displayRepresentation and a…

Discovery

How the system learns that your intents exist.

  1. How does the system find your intents, and why can they not be registered at runtime? 19.9.3 · L5
    Intents are discovered at build time. When an app or extension target is built, Xcode runs the App Intents metadata processor over the compiled module and…

More in Extensions, widgets & intents