View in English

  • Apple 开发者
    • 入门汇总

    探索“入门汇总”

    • 概览
    • 学习
    • Apple Developer Program

    及时了解最新动态

    • 最新动态
    • 开发者你好
    • 平台

    探索“平台”

    • Apple 平台
    • iOS
    • iPadOS
    • macOS
    • Apple tvOS
    • visionOS
    • watchOS
    • App Store

    精选

    • 设计
    • 分发
    • 游戏
    • 配件
    • 网页
    • Home
    • CarPlay 车载
    • 技术

    探索“技术”

    • 概览
    • Xcode
    • Swift
    • SwiftUI

    精选

    • 辅助功能
    • App Intents
    • Apple 智能
    • 游戏
    • 机器学习与 AI
    • 安全性
    • Xcode Cloud
    • 社区

    探索“社区”

    • 概览
    • “与 Apple 会面交流”活动
    • 社区主导的活动
    • 开发者论坛
    • 开源

    精选

    • WWDC
    • Swift Student Challenge
    • 开发者故事
    • App Store 大奖
    • Apple 设计大奖
    • Apple Developer Centers
    • 文档

    探索“文档”

    • 文档库
    • 技术概述
    • 示例代码
    • 《人机界面指南》
    • 视频

    发布说明

    • 精选更新
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • Apple tvOS
    • Xcode
    • 下载

    探索“下载”

    • 所有下载
    • 操作系统
    • 应用程序
    • 设计资源

    精选

    • Xcode
    • TestFlight
    • 字体
    • SF Symbols
    • Icon Composer
    • 支持

    探索“支持”

    • 概览
    • 帮助指南
    • 开发者论坛
    • “反馈助理”
    • 联系我们

    精选

    • 《开发者账户帮助》
    • 《App 审核指南》
    • 《App Store Connect 帮助》
    • 即将实行的要求
    • 协议和准则
    • 系统状态
  • 快速链接

    • 活动
    • 新闻
    • 论坛
    • 示例代码
    • 视频
 

视频

打开菜单 关闭菜单
  • 专题
  • 所有视频
  • 关于

更多视频

  • 简介
  • 概要
  • 代码
  • 探索 App Intents 框架的新功能

    利用高级功能提升 App Intents 的应用效果,从而打造更快速、更灵活、更相关的使用体验。了解如何使用 ValueRepresentation 和 RelevantEntities 让你的内容更易于发现并呈现在不同的 App 中,如何利用 EntityCollection 提升性能,以及如何借助 SyncableEntity 实现跨设备扩展。探索更丰富的参数类型,包括联合值以及能够顺畅处理取消事件的长时间运行意图。

    章节

    • 0:00 - Introduction
    • 2:40 - Share entities across apps with ValueRepresentation
    • 3:45 - Register relevant entities with RelevantEntities
    • 7:05 - Handle entities efficiently with EntityCollection
    • 8:55 - Use entities across devices with SyncableEntity
    • 11:01 - Richer parameter types
    • 12:38 - Union value parameters
    • 13:26 - Extend execution with LongRunningIntent
    • 15:27 - Target the right process with ExecutionTargets
    • 17:14 - Next steps

    资源

    • Adopting App Intents to support system experiences
    • App Intents
      • 高清视频
      • 标清视频
  • 搜索此视频…
    • 0:01 - Share structured entities with ValueRepresentation

      struct LandmarkEntity: AppEntity, Transferable {
            var id: Int
            var landmark: Landmark  // contains CLLocationCoordinate2D
      
            static var transferRepresentation: some TransferRepresentation {
                ValueRepresentation(
                    exporting: { entity in
                        PlaceDescriptor(
                            representations: [.coordinate(entity.landmark.locationCoordinate)],
                            commonName: entity.landmark.name
                        )
                    }
                )
            }
        }
      
        // If the entity already has a PlaceDescriptor property, use a key-path — much less code:
        struct LandmarkEntity: AppEntity, Transferable {
            var id: Int
            @Property var placeDescriptor: PlaceDescriptor
      
            static var transferRepresentation: some TransferRepresentation {
                ValueRepresentation(exporting: \.placeDescriptor)
            }
        }
    • 5:18 - Register relevant entities with RelevantEntities

      // Suggest playlists for the workout session
        let playlistEntities = [dailyRun, runningMix]
        let workoutContext = AppEntityContext.audio(.workout(activityType: .running))
      
        try await RelevantEntities.shared.updateEntities(
            playlistEntities, for: workoutContext
        )
        
        // Clear all entities for a context
        try await RelevantEntities.shared.removeAllEntities(for: workoutContext)
      
        // Remove specific entities from a context
        try await RelevantEntities.shared.removeEntities(playlistEntities, from: workoutContext)
      
        // Or remove all entities across all contexts
        try await RelevantEntities.shared.removeAllEntities()
    • 7:15 - Handle large entity sets with EntityCollection

      struct TagPhotosIntent: AppIntent {
            static let title: LocalizedStringResource = "Tag Travel Photos"
      
            @Parameter var photos: EntityCollection<PhotoEntity>   // was: [PhotoEntity]
            @Parameter var tag: String
      
            func perform() async throws -> some IntentResult {
                modelData.tagPhotos(ids: photos.identifiers, tag: tag)   // was: tagPhotos(photos, tag: tag)
                return .result()
            }
        }
    • 10:14 - Make entity IDs stable with SyncableEntity

      // If your ID is already stable across devices (server UUID, CloudKit record ID):
        struct PhotoEntity: AppEntity, SyncableEntity {
            var id: Int  // Already stable across devices — that's it
        }
        
        // If you use local IDs, pair a local and a stable ID:
        struct PhotoEntity: AppEntity, SyncableEntity {
            var id: SyncableEntityIdentifier<String, String>
      
            init(localID: String, stableID: String) {
                self.id = SyncableEntityIdentifier(local: localID, stable: stableID)
            }
        }
    • 11:58 - Accept multiple types with @UnionValue

      @UnionValue
        enum TravelGalleryContent {
            case landmarkCollection(LandmarkCollectionEntity)
            case photoAlbum(PhotoAlbumEntity)
      
            static let typeDisplayRepresentation: TypeDisplayRepresentation = "Travel Gallery"
            static let caseDisplayRepresentations: [Cases: DisplayRepresentation] = [
                .landmarkCollection: "Landmark Collection",
                .photoAlbum: "Photo Album"
            ]
        }
    • 13:41 - Run beyond 30 s with LongRunningIntent + CancellableIntent

      struct UploadPhotoIntent: LongRunningIntent, CancellableIntent {
            static let title: LocalizedStringResource = "Upload Photo"
      
            @Parameter var photo: IntentFile
        
            func perform() async throws -> some IntentResult & ProvidesDialog {
                let result = try await performBackgroundTask {
                    let chunks = calculateChunks(for: photo)
                    progress.totalUnitCount = Int64(chunks)
      
                    for chunk in 1...chunks {
                        try Task.checkCancellation()
                        try await uploadChunk(chunk)
                        progress.completedUnitCount = Int64(chunk)
                    }
                    return "Upload complete!"
                } onCancel: { reason in
                    cleanup(for: reason)
                }
                return .result(dialog: "\(result)")
            }
        }
    • 16:54 - Control which process runs your intent with ExecutionTargets

      // Write operation — needs the main app
        struct UpdateFavoriteIntent: AppIntent {
            static var allowedExecutionTargets: ExecutionTargets { .main }
        }
      
        // Standalone download — runs in the extension
        struct DownloadPhotoIntent: AppIntent {
            static var allowedExecutionTargets: ExecutionTargets { .appIntentsExtension }
        }
      
        // Display-only — runs in the widget extension
        struct GetLandmarkStatusIntent: AppIntent {
            static var allowedExecutionTargets: ExecutionTargets { .widgetKitExtension }
        }
      
        // Works in either — lets the system choose
        struct TagPhotosIntent: AppIntent {
            static var allowedExecutionTargets: ExecutionTargets { [.main, .appIntentsExtension] }
        }
    • 0:00 - Introduction
    • The 2027 App Intents updates — more control, flexibility, and a smoother developer experience across Siri, Shortcuts, Spotlight, Widgets, and Apple Intelligence. Three areas: entity enhancements, richer parameters, and intent execution, built on the Landmarks Travel Tracking sample.

    • 2:40 - Share entities across apps with ValueRepresentation
    • Beyond Transferable's File and Data representations, the new ValueRepresentation shares structured types the system understands, for example exporting a landmark as a PlaceDescriptor (GeoToolbox) so it flows to Maps for directions. Use a key-path if the entity already has the property.

    • 3:45 - Register relevant entities with RelevantEntities
    • Spotlight indexing and interaction donation can't surface never-seen, never-used content. RelevantEntities lets you suggest entities with a context (such as running playlists when a workout starts) via updateEntities, and remove them by context, by entity, or entirely.

    • 7:05 - Handle entities efficiently with EntityCollection
    • Resolving every entity before an intent runs is costly at scale (tagging thousands of photos). EntityCollection passes just identifiers to perform() without full resolution, a one-line parameter-type change that made tagging 1000 photos nearly instant.

    • 8:55 - Use entities across devices with SyncableEntity
    • Siri conversations now continue across devices, but local IDs differ per device. SyncableEntity declares a stable ID (server UUID or CloudKit record ID); when you only have local IDs, SyncableEntityIdentifier pairs a local and a stable ID so on-device code uses local and the system uses stable.

    • 11:01 - Richer parameter types
    • Declaring a @Parameter gives a native picker, Siri understanding, and localization for free, now extended to more native types like Duration (no custom time pickers) and PersonNameComponents, working across Siri, Shortcuts, and Widgets.

    • 12:38 - Union value parameters
    • A @UnionValue enum lets one parameter accept multiple types, for example a single widget showing photos from either a landmark collection or a photo album. The macro generates type info, case metadata, and picker support (typeDisplayRepresentation, caseDisplayRepresentations), and works everywhere including Shortcuts.

    • 13:26 - Extend execution with LongRunningIntent
    • Intents normally have 30 seconds; LongRunningIntent runs beyond it, manages the background task lifecycle, and shows progress as a Live Activity. Wrap work in performBackgroundTask and report progress (it builds on ProgressReportingIntent). Add CancellableIntent's onCancel to clean up gracefully; it also supports background GPU access.

    • 15:27 - Target the right process with ExecutionTargets
    • When intents live in a shared package linked by the app and extensions, the system picks a process by heuristics, not always right (for example a widget favorite button needs the writing main app). ExecutionTargets overrides this to target the main app, an App Intents extension, a WidgetKit extension, or any combination.

    • 17:14 - Next steps
    • Add ValueRepresentation to carry structured data, register relevant content, adopt EntityCollection for large entity sets, and add LongRunningIntent for work over 30 seconds. See "Code-along: Make your app available to Siri" and "Validate your App Intents adoption with AppIntentsTesting."

Developer Footer

  • 视频
  • WWDC26
  • 探索 App Intents 框架的新功能
  • 打开菜单 关闭菜单
    • iOS
    • iPadOS
    • macOS
    • Apple tvOS
    • visionOS
    • watchOS
    打开菜单 关闭菜单
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • SF Symbols
    打开菜单 关闭菜单
    • 辅助功能
    • 配件
    • Apple 智能
    • App 扩展
    • App Store
    • 音频与视频 (英文)
    • 增强现实
    • 设计
    • 分发
    • 教育
    • 字体 (英文)
    • 游戏
    • 健康与健身
    • App 内购买项目
    • 本地化
    • 地图与位置
    • 机器学习与 AI
    • 开源资源 (英文)
    • 安全性
    • Safari 浏览器与网页 (英文)
    打开菜单 关闭菜单
    • 完整文档 (英文)
    • 部分主题文档 (简体中文)
    • 教程
    • 下载
    • 论坛 (英文)
    • 视频
    打开菜单 关闭菜单
    • 支持文档
    • 联系我们
    • 错误报告
    • 系统状态 (英文)
    打开菜单 关闭菜单
    • Apple 开发者
    • App Store Connect
    • 证书、标识符和描述文件 (英文)
    • 反馈助理
    打开菜单 关闭菜单
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program (英文)
    • Mini Apps Partner Program
    • News Partner Program (英文)
    • Video Partner Program (英文)
    • 安全赏金计划 (英文)
    • Security Research Device Program (英文)
    打开菜单 关闭菜单
    • 与 Apple 会面交流
    • Apple Developer Center
    • App Store 大奖 (英文)
    • Apple 设计大奖
    • Apple Developer Academies (英文)
    • WWDC
    阅读最近新闻。
    获取 Apple Developer App。
    版权所有 © 2026 Apple Inc. 保留所有权利。
    使用条款 隐私政策 协议和准则