Jump to content

SwiftUI

From VR & AR Wiki
SwiftUI
Information
Type User interface framework
Industry Software development
Developer Apple
Written In Swift
Operating System iOS, iPadOS, macOS, watchOS, tvOS, visionOS
License Proprietary
Supported Devices Apple Vision Pro, iPhone, iPad, Mac, Apple Watch, Apple TV
Release Date June 3, 2019
Website https://developer.apple.com/xcode/swiftui/

Property "Written In" (as page type) with input value "Swift (programming language)|Swift" contains invalid characters or is incomplete and therefore can cause unexpected results during a query or annotation process.

SwiftUI is a declarative user interface framework developed by Apple for building applications across its operating systems, including iOS, iPadOS, macOS, watchOS, tvOS, and visionOS.[1] Apple announced it at the Worldwide Developers Conference (WWDC) on June 3, 2019, and shipped the first version with iOS 13 and macOS Catalina.[1][2] SwiftUI is written in and used through the Swift programming language, and it describes interfaces declaratively rather than with the imperative, view-by-view code used by Apple's older UIKit and AppKit frameworks.[1][2]

For VR and AR, SwiftUI is the primary framework Apple recommends for building apps on visionOS, the operating system that runs on Apple Vision Pro. Apple states that SwiftUI is "the best way to build a new visionOS app or bring your existing iOS or iPadOS app to the visionOS platform," and that the framework gained "all-new 3D capabilities and support for depth, gestures, effects, and immersive scene types" for spatial computing.[3] On visionOS, SwiftUI defines the app's windows, three-dimensional volumes, and fully immersive spaces, and it is integrated with Apple's RealityKit 3D rendering engine.[3][4]

Background and design

SwiftUI uses a declarative programming model: a developer describes what the interface should contain for a given state, and the framework generates and updates the rendered views to match, rather than the developer manually mutating view objects.[2][1] Apple presented this as a way to reduce the amount of UI code compared with UIKit and AppKit.[2] Interfaces are built by composing values that conform to the framework's view protocol, and the framework keeps the displayed content synchronized with the underlying application state through its data-binding mechanism.[1]

SwiftUI is proprietary software and is distributed as part of Apple's SDKs rather than as an open-source project; as of 2025 Apple had not released the SwiftUI source code or announced plans to do so, although other parts of the Swift ecosystem, such as Swift Build and the Foundation library, have been open-sourced.[5] The framework interoperates with Apple's earlier UI toolkits: a UIKit view can be wrapped for use in SwiftUI through the UIViewRepresentable protocol, and an AppKit view through NSViewRepresentable.[1]

Capabilities

On its 2D platforms SwiftUI supports drawing, animation, event handling, widgets, and data binding, with the displayed interface kept in sync with the application's data automatically.[1] Later releases extended the framework with additional components tied to specific operating system versions.

OS release (year) Notable SwiftUI addition
iOS 13 / macOS Catalina (2019) Initial release of the framework[1][2]
iOS 14 (2020) Map view backed by MapKit[1]
iOS 15 (2021) Canvas element for immediate-mode 2D drawing[1]
iOS 16 (2022) Swift Charts framework for data visualization[1]
visionOS (2023) RealityView and ImmersiveSpace scene types for 3D and AR content[1]

Role in VR and AR

SwiftUI is the main application framework for spatial computing on visionOS. Apple introduced visionOS at WWDC 2023 on June 5, 2023, alongside the Apple Vision Pro headset, and the platform shipped when Vision Pro went on sale in the United States on February 2, 2024, starting at 3,499 US dollars.[6][7] Apple describes visionOS apps as being built from three kinds of SwiftUI content: windows, volumes, and spaces.[3]

  • Windows are SwiftUI scenes that hold conventional 2D views and controls and can also contain 3D content with depth. They are created with the standard WindowGroup scene type.[3][4]
  • Volumes are bounded 3D containers that show RealityKit content viewable from any angle. A SwiftUI WindowGroup becomes a volume by applying the volumetric window style, written as .windowStyle(.volumetric).[4]
  • Spaces control how much of the user's surroundings an app occupies. By default apps run in a Shared Space alongside other apps; an app can instead open a Full Space for a single, immersive experience. Immersive content is presented through SwiftUI's ImmersiveSpace scene type, which can render content that integrates with or replaces the user's real surroundings.[3][4]

3D RealityKit content is brought into a SwiftUI hierarchy with the RealityView view, which can display models in a volume or within an immersive space.[4] SwiftUI on visionOS also adds ornaments, which place controls in a bar attached to the outside edge of a window, created with the ornament view modifier.[4] Apple states that RealityKit is "deeply integrated with SwiftUI" to build volumetric interfaces, and that ARKit capabilities such as plane detection, scene reconstruction, image anchoring, world tracking, and hand tracking are available to apps running in a Full Space.[3]

Because visionOS reuses Apple's existing developer frameworks, apps written with SwiftUI for iOS and iPadOS can run on Vision Pro, and at launch Apple said more than one million iOS and iPadOS apps were available on the headset and worked with its input system.[7]

Current status

SwiftUI continues to be Apple's recommended UI framework and is updated each year with the company's operating systems. At WWDC 2025 Apple added spatial layout features to SwiftUI for visionOS, including a spatial overlay for layering 2D and 3D content, 3D alignment of interface elements, a manipulable modifier that makes content draggable and resizable, and scene snapping that aligns objects to real-world surfaces such as walls and tables. The same update added support for spatial widgets that can snap to surfaces and adjust their detail based on the viewer's distance, and tighter ties between SwiftUI and RealityKit, including attaching SwiftUI gestures directly to RealityKit entities.[8]

References