@Environment
Asked on 03/05/2025
1 search
The @Environment
property wrapper in SwiftUI is used to read values from the environment. It allows you to access shared data or actions that are available throughout the SwiftUI view hierarchy. For example, in the session Work with windows in SwiftUI, an environment property is used to retrieve an open window action by creating an environment property with a keypath of open window. This allows you to perform actions like opening or closing windows within your SwiftUI app.
If you have more specific questions about how @Environment
is used in SwiftUI or need further details, feel free to ask!

Create custom environments for your immersive apps in visionOS
Discover how to create visually rich and performant customized app environments for Apple Vision Pro. Learn design guidelines, get expert recommendations, and explore techniques you can use in any digital content creation tool to begin building your immersive environment.

SwiftUI essentials
Join us on a tour of SwiftUI, Apple’s declarative user interface framework. Learn essential concepts for building apps in SwiftUI, like views, state variables, and layout. Discover the breadth of APIs for building fully featured experiences and crafting unique custom components. Whether you’re brand new to SwiftUI or an experienced developer, you’ll learn how to take advantage of what SwiftUI has to offer when building great apps.

Get started with HealthKit in visionOS
Discover how to use HealthKit to create experiences that take full advantage of the spatial canvas. Learn the capabilities of HealthKit on the platform, find out how to bring an existing iPadOS app to visionOS, and explore the special considerations governing HealthKit during a Guest User session. You’ll also learn ways to use SwiftUI, Swift Charts, and Swift concurrency to craft innovative experiences with HealthKit.