场景 032 · Codex Use Case

添加 iOS App Intents

识别应向系统暴露的操作与实体,通过 App Intents 接入 Shortcuts、Spotlight 等入口,逐步支持助手驱动的流程。

iOSCode
Add iOS app intentsiOSCode

原文核对:2026-10-13 · 中文正文 · 英文提示词与演示

场景定位

识别应向系统暴露的操作与实体,通过 App Intents 接入 Shortcuts、Spotlight 等入口,逐步支持助手驱动的流程。

难度
高级
时间跨度
1 小时

适合用于

  • 已有有用操作或内容,但尚未接入 Shortcuts、Siri、Spotlight 的应用。
  • 希望先开放少数高价值操作,再逐步支持助手的团队。
  • 具有账号、列表、筛选、目标、草稿或媒体等清晰对象的应用。

相关工具

Build iOS Apps

添加 App Intents、实体和 App Shortcuts,并验证构建及系统入口的运行路由。

Build iOS Apps ↗

起步提示词

英文原文 · 可复制后按实际材料修改

Use the Build iOS Apps plugin to audit this iOS app and add App Intents for the actions and entities that should be exposed to the system.

Constraints:
- Start by identifying the app's highest-value user actions and core objects that should be available outside the app in Shortcuts, Siri, Spotlight, widgets, controls, or newer assistant-driven system surfaces.
- Keep the first pass focused. Pick a small set of intents that are genuinely useful without opening the full app, plus any open-app intents that should deep-link into a specific screen or workflow.
- Define app entities only for the data the system actually needs to understand and route those actions. Do not mirror the entire internal model layer if a smaller entity surface is enough.
- Add App Shortcuts where they make the experience more discoverable, and choose titles, phrases, and display representations that would make sense in Siri, Spotlight, and Shortcuts.
- If the app needs to handle the intent inside the main UI, route the result back into the app cleanly and explain how the app scene reacts to that handoff.
- Build and validate the app after the first pass, then summarize which actions, entities, and system surfaces are now supported.

Deliver:
- the recommended intent and entity surface for a first release
- the implemented intents, entities, and App Shortcuts
- how the app routes or handles those intents at runtime
- which Apple system experiences this unlocks now and which ones are logical next steps

向系统开放合适能力

用 Codex 将操作与对象暴露给 Shortcuts、Siri、Spotlight、widget、control 和新的助手系统体验,让能力不局限于应用内部 UI。

这既改善发现与自动化,也为助手驱动的使用方式做准备。撰写、打开、筛选、路由或摘要等有用能力,可以通过结构化接口被系统调用。

从操作和实体开始

首轮通常不应映射整款应用,而应识别:

  • 无需遍历完整界面就值得直接触发的少数操作。
  • 系统正确路由所需理解的对象。
  • 哪些流程应打开应用到指定状态,哪些可直接从系统入口完成。

遵循 Apple 指南:定义操作、定义所需实体,再让操作在系统体验中可发现和复用。可参考 Making actions and content discoverable and widely available、Creating your first app intent,以及 Adopting App Intents to support system experiences。

考虑多种系统入口

App Intents 不只用于一个快捷指令,还可用于:

  • Shortcuts:直接运行或组合为更大的自动化。
  • Siri:暴露明确动作和深链,而非仅打开应用。
  • Spotlight:通过实体与快捷方式提供可发现入口。
  • widget、Live Activities、control 等意图驱动界面。
  • 新的助手体验:结构化操作和实体比任意 UI 路径更容易理解。

采用实际应用结构

建议结构包括:

  • 独立的 App Intents target,避免类型散落在无关文件中。
  • 通过 AppShortcutsProvider 注册撰写内容、打开指定标签页等高价值操作。
  • 小型 AppEntity 描述账号、列表和时间线筛选等对象。
  • 意图处理清晰交回主场景,打开正确撰写流程或切换到正确标签页。

先建立小型系统操作层,缩小实体范围;需要主 UI 时,提供可预测的运行时交接。

设计第一组意图

提供核心对象和主要用户动作,让 Codex 选择最小有用的首批接口,而非全部暴露。

实用建议

暴露用户在应用外需要的动作

首批通常包括撰写、打开、查找、筛选、开始、继续或查看。依赖长串应用内准备的操作可能不适合首轮。

实体小于完整模型层

定义足以让 Siri、Shortcuts 和 Spotlight 正确路由与展示的最小实体,不必开放整个持久化模型。

作为助手基础设施来设计

即使首版只改善 Shortcuts 或 Siri,结构化操作和实体也让应用更易接入后续系统与 AI 入口。

技术栈

需要默认选项用途
开放操作App IntentsApp Intents ↗使操作可用于 Shortcuts、Siri、Spotlight、widget、control 和助手入口。
数据接口AppEntity、EntityQuery 和显示表示让系统理解必要对象,不暴露完整模型层。
可发现性AppShortcutsProvider、明确短语、标题和图标让首批操作无需用户从零配置即可发现和运行。
验证循环xcodebuild、模拟器与运行时路由检查不仅编译成功,还需证明调用后打开或路由到正确位置。
展开英文原文对照

Use Codex and the Build iOS Apps plugin to identify the actions and entities your app should expose through App Intents, wire them into system surfaces like Shortcuts and Spotlight, and prepare your app for more assistant-driven workflows over time.

Make the right parts of your app visible to the system

App Intents are one of the clearest ways to make an iOS app more useful outside its own UI. Instead of treating your app as a sealed destination that only works after someone launches it and taps around, use Codex to expose the actions and objects that should be available to Shortcuts, Siri, Spotlight, widgets, controls, and newer assistant-driven system experiences.

That is useful today for discoverability and automation, and it is a strong preparation step for a more assistant-driven future. If your app already knows how to compose, open, filter, route, or summarize something valuable, App Intents give the system a structured way to ask for that capability.

Start with actions and entities, not with every screen

The best first App Intents pass is usually not “mirror the whole app.” Ask Codex to identify:

  • the few actions a user would want to trigger without navigating the full interface
  • the app objects the system needs to understand to route those actions correctly
  • the workflows that should open the app in a specific state versus the ones that should complete directly from a system surface

Apple’s App Intents guidance is a good frame here: define the action, define the entity surface the system needs, then make those actions discoverable and reusable across system experiences. The most useful references are Making actions and content discoverable and widely available, Creating your first app intent, and the system-experience sample Adopting App Intents to support system experiences.

Think in system surfaces, not just in shortcuts

The opportunity is broader than “add one shortcut.” A good App Intents surface can make your app useful in several places:

  • Shortcuts, where users can run actions directly or compose them into larger automations
  • Siri, where the app can expose meaningful verbs and deep links instead of only opening generically
  • Spotlight, where app entities and app shortcuts become discoverable system entry points
  • widgets, Live Activities, controls, and other intent-driven UI surfaces
  • newer assistant-facing experiences, where structured actions and entities are much easier for the system to understand than arbitrary UI flows

Follow a real app pattern

This usually works best when the app adopts a structure like this:

  • a dedicated App Intents target instead of scattering intent types across unrelated app files
  • AppShortcutsProvider entries for high-value user actions like composing a post or opening the app on a specific tab
  • small AppEntity types for things the system needs to reason about, such as accounts, lists, and timeline filters
  • intent handling that routes back into the main app scene cleanly, so an invoked intent can open the right compose flow or switch the app to the right tab

That is the pattern I would ask Codex to follow for most apps: start with a small system-facing action layer, keep the entity surface narrow, and wire a predictable runtime handoff back into the app when the intent needs the main UI.

Ask Codex to design the first intent surface

The strongest prompt here is one that gives Codex your app’s core objects and top user actions, then asks it to choose the smallest useful first App Intents surface instead of blindly exposing everything.

Practical tips

Expose verbs users actually want outside the app

Good first intents are usually things like compose, open, find, filter, start, continue, or inspect. If an action is only useful after a long in-app setup flow, it may not belong in the first App Intents pass.

Keep entities smaller than your model layer

The system usually does not need your full persistence model. Ask Codex to define the smallest app entity surface that still gives Siri, Shortcuts, and Spotlight enough context to route and display the action correctly.

Treat this as assistant infrastructure, not only a shortcuts feature

Even if your first release only visibly improves Shortcuts or Siri, the deeper win is that your app starts speaking in structured actions and entities. That makes it easier to participate in future system and AI-driven entry points than an app whose capabilities are only encoded in taps and view hierarchies.