View in English

  • Apple 开发者
    • 入门汇总

    探索“入门汇总”

    • 概览
    • 学习
    • Apple Developer Program

    及时了解最新动态

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

    探索“平台”

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

    精选

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

    探索“技术”

    • 概览
    • Xcode
    • Swift
    • SwiftUI

    精选

    • 辅助功能
    • AI 与机器学习
    • App Intents
    • Apple 智能
    • 游戏
    • 安全性
    • 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 帮助》
    • 即将实行的要求
    • 协议和准则
    • 系统状态
  • 快速链接

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

视频

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

更多视频

  • 简介
  • 概要
  • SwiftUI 小组实验室

    参加我们的线上活动,与 Apple 工程师和设计师一起深入探索 WWDC26。在这个以 SwiftUI 为主题的活动中,你可以提出问题、获取建议,并实时关注围绕大会一周的相关重磅发布展开的精彩讨论。活动语言为英语。

    章节

    • 0:00:00 - Introduction
    • 0:01:03 - Is there an architecture (MVC, MVVM, VIPER, Clean Architecture, etc.) the SwiftUI team expects us to adopt, or is SwiftUI intentionally architecture-agnostic?
    • 0:04:31 - What's the difference between a @ViewBuilder closure and a separate view struct, and what are the performance pros and cons of each?
    • 0:10:19 - What are the most common anti-patterns in SwiftUI you've seen lately?
    • 0:17:26 - What's one concept in SwiftUI that takes developers the longest to understand, and how would you explain it?
    • 0:24:00 - In UIKit, cell reuse was fundamental to scrolling performance. Are lazy stacks and grids enough for infinitely scrolling layouts in SwiftUI, or should you drop down to a hosted UICollectionView?
    • 0:26:55 - The change from @ViewBuilder to @ContentBuilder looks great — how does it work, and why did it improve type-checking performance?
    • 0:29:52 - When your teams hit a mystery re-render storm, what's the real workflow — the new SwiftUI Instrument, Self._printChanges, or something else? And why the underscore?
    • 0:34:18 - With the @ContentBuilder compilation improvements, is there any reason to keep using @ViewBuilder, and when should we choose each?
    • 0:35:26 - SwiftUI property wrappers feel like opaque magic. If I don't fully grasp how @State manages its lifecycle, how can I safely adopt Swift Concurrency — what's the mental model connecting them?
    • 0:38:32 - What's the recommended way to implement navigation in iOS 27 if custom transitions are required — SwiftUI or UIKit+SwiftUI?
    • 0:40:38 - What's the recommended way to track a ScrollView's scrolling offset, to show certain view elements based on how far the user has scrolled?
    • 0:43:41 - Is there a way to build custom layouts that are lazy, similar to LazyVStack?
    • 0:45:15 - What's the most common mistake in large SwiftUI apps that ends up hurting performance?
    • 0:48:39 - Do @Observable properties automatically get allocated on the correct thread, or should we explicitly mark UI-referenced properties @MainActor?
    • 0:53:28 - In our multi-module app we return AnyView from protocols to hide concrete view types and avoid cross-module dependencies. Is there a more idiomatic way without AnyView?
    • 0:56:13 - Can you explain the performance tradeoffs (speed and memory) of compositingGroup, geometryGroup, and drawingGroup?

    资源

      • 高清视频
      • 标清视频
  • 搜索此视频…
    • 0:00:00 - Introduction
    • Engineers from the SwiftUI team introduce themselves and set up a session covering SwiftUI architecture, view identity and updates, performance and view invalidation, the ContentBuilder change, navigation and scroll APIs, lazy layouts, and concurrency with @Observable and @State.

    • 0:01:03 - Is there an architecture (MVC, MVVM, VIPER, Clean Architecture, etc.) the SwiftUI team expects us to adopt, or is SwiftUI intentionally architecture-agnostic?
    • SwiftUI doesn't prescribe an architecture — it's designed to be architecture-agnostic, so use whatever pattern fits your app. @Observable helps here: it can model your data in AppKit/UIKit today and eases the transition to SwiftUI, and it's plain Swift not tied to any UI framework. If your chosen architecture integrates poorly or feels awkward passing data around, file feedback so the team can improve the ergonomics.

    • 0:04:31 - What's the difference between a @ViewBuilder closure and a separate view struct, and what are the performance pros and cons of each?
    • Both are valid; the choice is about clarity more than raw performance. Breaking a large body into smaller pieces makes views easier to reason about — a separate view struct gives SwiftUI a distinct identity and its own dependency tracking, so it can update independently, while a @ViewBuilder computed property is inlined into the parent and re-evaluates with it. Prefer separate view types when a subsection has its own state or should update on its own.

    • 0:10:19 - What are the most common anti-patterns in SwiftUI you've seen lately?
    • A frequently cited one is overusing GeometryReader — audit where you use it and prefer the Layout protocol (introduced a few years ago) where possible. More broadly, watch for patterns that cause excessive view invalidation. The framing the team prefers is less "anti-pattern" and more knowing the idiomatic right way to express layout and state.

    • 0:17:26 - What's one concept in SwiftUI that takes developers the longest to understand, and how would you explain it?
    • The hidden part is how SwiftUI updates via an internal graph — nodes represent views and edges represent their inputs (dependencies). SwiftUI uses that structure to determine which parts of your hierarchy need to update when data changes. Understanding that your view's inputs define its update behavior is the mental model that unlocks most performance and correctness questions.

    • 0:24:00 - In UIKit, cell reuse was fundamental to scrolling performance. Are lazy stacks and grids enough for infinitely scrolling layouts in SwiftUI, or should you drop down to a hosted UICollectionView?
    • UIKit relied on cell reuse mainly because views are reference types allocated on the heap, so every row carried a fixed allocation cost plus the overhead of inserting and removing it from the hierarchy. SwiftUI doesn't have that same problem, so you generally don't need to reach for a hosted UICollectionView. Lazy stacks and grids also bring real advantages: implicit prefetching starts evaluating the view bodies of cells about to scroll on screen, and because the view graph is made of individual nodes, SwiftUI can partially evaluate the next cell in the time left after rendering the current frame, then pause right before the next frame. One performance caveat: reconfiguring a cell's state in onAppear can change its size and force it to lay out again, throwing away that prefetched work — so do that setup in the initializer rather than in body or onAppear. As with onChange, prefer letting your data model drive changes, since both onChange and onAppear live in the view body and force it to recompute.

    • 0:26:55 - The change from @ViewBuilder to @ContentBuilder looks great — how does it work, and why did it improve type-checking performance?
    • See the What's New in SwiftUI talk for a visual walkthrough. The change reworks how the result builder is structured so the compiler type-checks builder content more efficiently, reducing the combinatorial type-checking cost that could make large view bodies slow to compile — without changing how you write your views.

    • 0:29:52 - When your teams hit a mystery re-render storm, what's the real workflow — the new SwiftUI Instrument, Self._printChanges, or something else? And why the underscore?
    • The recommended path is the SwiftUI Instrument, which visualizes updates and shows which views are re-evaluating and why. Self._printChanges remains a handy quick check for what caused a view to update; the underscore signals it's a debugging aid rather than stable API. Use the Instrument for systematic investigation of over-updating.

    • 0:34:18 - With the @ContentBuilder compilation improvements, is there any reason to keep using @ViewBuilder, and when should we choose each?
    • ContentBuilder and ViewBuilder are effectively the same — ContentBuilder is a type alias — so existing @ViewBuilder code keeps working unchanged. The one meaningful difference is reach: ContentBuilder can be used outside of views, so you can build your own SwiftUI-like DSLs and result-builder-based building blocks that aren't SwiftUI views. If you don't need that, there's nothing you have to change.

    • 0:35:26 - SwiftUI property wrappers feel like opaque magic. If I don't fully grasp how @State manages its lifecycle, how can I safely adopt Swift Concurrency — what's the mental model connecting them?
    • SwiftUI runs your view updates on the main actor, so @State and view body evaluation happen on the main thread by default — that's the anchor. Concurrency is about moving work off the main actor and bringing results back. You don't need to master @State's internal storage; the model is: UI state lives on the main actor, do async work elsewhere, and update that state back on the main actor.

    • 0:38:32 - What's the recommended way to implement navigation in iOS 27 if custom transitions are required — SwiftUI or UIKit+SwiftUI?
    • It depends on your app's needs, but iOS 27 adds a new SwiftUI API for customizing navigation transitions, with built-in support for cross-fades and other custom transitions. If those cover your case, stay in SwiftUI; only reach for UIKit interop when you need a transition the new API doesn't support.

    • 0:40:38 - What's the recommended way to track a ScrollView's scrolling offset, to show certain view elements based on how far the user has scrolled?
    • There are a few APIs depending on what you need: the onGeometryChange modifier, scroll effects (which offload work and are more efficient in some cases), and the scrollPosition modifier to know which item is currently on screen. Treat the raw content offset as an implementation detail — with lazy stacks it's only estimated from off-screen view heights and has no reliable semantic meaning — and instead trigger changes relative to the views actually on screen. There's also an API (covered in Rens' talk) for tracking what percentage of a view is visible, which is ideal for analytics or impression tracking. And a common way to build infinite scrolling is to put a view at the bottom of the list whose onAppear tells your networking layer to fetch more data.

    • 0:43:41 - Is there a way to build custom layouts that are lazy, similar to LazyVStack?
    • Not today — there's no protocol for describing a custom lazy layout; the Layout protocol is eager. If this matters for your use case, file a Feedback request with details, since developer demand helps prioritize adding it.

    • 0:45:15 - What's the most common mistake in large SwiftUI apps that ends up hurting performance?
    • Too much invalidation cascading from the top. A frequent cause is putting something high in the environment that many downstream views read — when it changes, everything observing it re-evaluates. Scope state so changes invalidate only the views that actually depend on them, rather than triggering wide downstream updates.

    • 0:48:39 - Do @Observable properties automatically get allocated on the correct thread, or should we explicitly mark UI-referenced properties @MainActor?
    • SwiftUI operates on the main actor, so state that views read is exercised on the main thread. Rather than annotating every property, let UI-facing state live on the main actor by default and only move computation off it deliberately. Decide where state lives based on who uses it: keep view-driving @Observable state main-actor-aligned, and isolate background work separately.

    • 0:53:28 - In our multi-module app we return AnyView from protocols to hide concrete view types and avoid cross-module dependencies. Is there a more idiomatic way without AnyView?
    • Prefer keeping type information over erasing it with AnyView. Use @ViewBuilder and an associated type (some View) on your protocol, or opaque return types, so the concrete view type stays hidden across module boundaries without paying AnyView's cost. Reserve AnyView for cases where you genuinely need heterogeneous, type-erased views.

    • 0:56:13 - Can you explain the performance tradeoffs (speed and memory) of compositingGroup, geometryGroup, and drawingGroup?
    • They serve different purposes. compositingGroup isn't primarily a performance tool — it flattens a subtree so visual effects apply to it as a whole. drawingGroup rasterizes content off-screen (via Metal), which can help with complex static visuals but costs memory and isn't free, so measure before using. geometryGroup isolates geometry changes so animations resolve correctly. Choose based on the effect you need, and profile rather than applying them speculatively.

开发者页脚

  • 视频
  • WWDC26
  • SwiftUI 小组实验室
  • 打开菜单 关闭菜单
    • iOS
    • iPadOS
    • macOS
    • Apple tvOS
    • visionOS
    • watchOS
    • App Store
    打开菜单 关闭菜单
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    打开菜单 关闭菜单
    • 辅助功能
    • 配件
    • AI 与机器学习
    • Apple 智能
    • 音频与视频
    • 增强现实
    • 商务
    • 设计
    • 分发
    • 教育
    • 游戏
    • 健康与健身
    • App 内购买项目
    • 本地化
    • 地图与位置
    • 安全性
    • 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 Academy
    • WWDC
    阅读最近新闻。
    获取 Apple Developer App。
    版权所有 © 2026 Apple Inc. 保留所有权利。
    使用条款 隐私政策 协议和准则