讓 App Intents 更可被系統理解:entities、parameters、execution 三條主線
這場 session 聚焦 App Intents 的進階能力:讓 entity 能跨 app 與跨裝置流動、讓大型 entity set 不拖慢執行、讓參數型別更貼近人類語意,並讓長時間 intent 有背景任務與進度 UI。
Apple 正把 App Intents 從「把 action 暴露給 Siri/Shortcuts」推向「讓 app content 成為系統可理解、可推薦、可跨裝置執行的語意層」。
這支影片在拆三類 App Intents 擴展痛點
內容要能被其他 app 與裝置理解
ValueRepresentation 讓 entity 輸出系統懂的結構化型別;SyncableEntity 則用 stable ID 解決跨裝置 local ID 不一致問題。
沒互動過的內容也要能被系統推薦
Spotlight indexing 與 interaction donation 只能反映已看過或已做過的內容。RelevantEntities 讓 app 主動提供特定情境下最相關的 entity。
大量 entity 不應在執行前全部 resolve
例如給上千張照片加 tag,如果每張都先 resolve 成完整 entity,intent 執行前就會慢。EntityCollection 讓 perform() 收到 ID collection,按需處理。
Intent 需要更長時間、更精準 process 與取消處理
LongRunningIntent 解開 30 秒限制並搭配 Live Activity progress;ExecutionTargets 讓 shared package 裡的 intent 指定該跑在 app、extension 或 widget。
導入新 App Intents primitive 的判斷路徑
內容要交給其他 app 使用:加 ValueRepresentation
如果 entity 其實代表地點、聯絡人、檔案或其他系統已知概念,提供 structured value,比只靠 Transferable 的 file/data representation 更有語意。
內容需要在特定情境被推薦:註冊 RelevantEntities
在 workout、trip、editing session 等情境啟動時呼叫 updateEntities,結束時依 context 或 entity 移除,避免系統推薦過期內容。
entity 數量很大:改用 EntityCollection
若 bottleneck 是 intent 執行前的 entity resolution,把 parameter type 改成 collection,讓 perform() 用 identifiers 操作,避免預先載入全部資料。
跨裝置對話要延續:實作 SyncableEntity
用 server UUID 或 CloudKit record ID 作 stable ID;若只有 local ID,使用 SyncableEntityIdentifier 同時提供 local 與 stable mapping。
工作超過 30 秒或要指定 process:加 LongRunningIntent / ExecutionTargets
長工作包進 performBackgroundTask、回報 progress、處理 cancellation;shared package 則用 execution targets 指定 main app 或 extension。
重點 1:Entity 不只是 app 內資料,還要能被系統語意化
App Intents 原本就能讓 Siri、Shortcuts、Spotlight、Widgets 與 Apple Intelligence 使用 app 的 action 和 content。WWDC26 這場 session 的新方向,是讓 entity 更像系統語意網路的一部分:能轉成其他 app 懂的結構、能在正確情境被推薦、能在大量資料與多裝置情境下保持穩定。
影片範例用 Landmarks Travel Tracking app 說明:landmark 可以用 ValueRepresentation 匯出成 GeoToolbox 的 PlaceDescriptor,讓 Maps 可以直接拿去做 directions,而不是只能作為 app 自己的 opaque object。
重點 2:參數型別越貼近語意,系統 UI 與語音理解越不用自建
影片提醒,宣告 @Parameter 不只是拿到一個 Swift 參數;系統會自動提供 native picker、Siri understanding 與 localization。WWDC26 擴充更多 native types,例如 Duration 與 PersonNameComponents,讓開發者不用為常見語意重做自訂 picker 或 parsing。
@UnionValue 則處理另一種常見需求:一個參數可接受多種型別。例如 widget 可以顯示「landmark collection」或「photo album」其中之一;macro 會生成型別資訊、case metadata 與 picker 支援,並可用在 Shortcuts 等系統入口。
重點 3:Long-running intent 把背景任務、進度與取消拉進標準模型
傳統 intent 通常有 30 秒限制。LongRunningIntent 讓更長的工作可被系統管理背景任務 lifecycle,並透過 Live Activity 顯示 progress。這對匯出、批次處理、生成內容、長時間影像/資料處理很重要。
風險與遷移注意事項
章節索引
來源
主要來源為 Apple Developer 官方影片頁、官方 transcript、章節與 documentation links;YouTube 影片頁用於 iframe 與發布 metadata。官方頁:Discover new capabilities in the App Intents framework - WWDC26。YouTube:WWDC26: Discover new capabilities in the App Intents framework | Apple。相關文件:App Intents。
- 01App Intents 新能力集中在 entity enhancements、richer parameters、intent execution 三條主線。
- 02ValueRepresentation 讓 entity 跨 app 共享時保留系統可理解的 structured value。
- 03RelevantEntities 與 EntityCollection 分別解決推薦情境與大量 entity resolution 成本。
- 04SyncableEntity 要用跨裝置 stable ID,避免 Siri conversation 在不同裝置斷掉。
- 05LongRunningIntent、CancellableIntent 與 ExecutionTargets 讓長工作、取消與 process routing 更可控。