What's New / Spatial, 3D & RealityKit

What's new in SpatialPreview

+29 NewmacOS

SpatialPreview connects an authoring app to a paired spatial device and sends 3D and document content over a session for live preview. Its API centers on preview sessions, connected endpoints, and a SwiftUI device picker.

The 27 SDK adds 29 APIs with no deprecations or removals. The session layer is new: the SpatialPreviewSession protocol, SpatialPreviewEndpoint, the SpatialPreviewSessionError and SpatialPreviewSessionState enums, ConnectedSpatialEndpointObserver, and DocumentPreviewSession. SpatialPreviewDevicePicker (with its Body type) is a new SwiftUI view. New OptimizationParameters and OptimizationSteps types ship alongside Event and Error enums.

New

29
extension

ConnectedSpatialEndpointObserver

NewmacOS
extension ConnectedSpatialEndpointObserver : nonisolated Observable
Declaration
extension ConnectedSpatialEndpointObserver : nonisolated Observable {
}
extension

ConnectedSpatialEndpointObserver

NewmacOS
extension ConnectedSpatialEndpointObserver : Sendable
Declaration
extension ConnectedSpatialEndpointObserver : Sendable {
}
extension

DocumentPreviewSession

NewmacOS
extension DocumentPreviewSession : Observable
Declaration
extension DocumentPreviewSession : Observable {
}
extension

DocumentPreviewSession

NewmacOS
extension DocumentPreviewSession : Sendable
Declaration
extension DocumentPreviewSession : Sendable {
}
enum

Error

NewmacOS
public enum Error : Error

Errors that can occur during a USD preview session

Declaration
public enum Error : Error {

    /// The stage became too complex to sync.
    case assetUnshareable

    /// The stage was replaced during optimization and any changes made to the stage won't be synced.
    case readOnlyStage

    /// Returns a Boolean value indicating whether two values are equal.
    ///
    /// Equality is the inverse of inequality. For any values `a` and `b`,
    /// `a == b` implies that `a != b` is `false`.
    ///
    /// - Parameters:
    ///   - lhs: A value to compare.
    ///   - rhs: Another value to compare.
    public static func == (a: USDPreviewSession.Error, b: USDPreviewSession.Error) -> Bool

    /// Hashes the essential components of this value by feeding them into the
    /// given hasher.
    ///
    /// Implement this method to conform to the `Hashable` protocol. The
    /// components used for hashing must be the same as the components compared
    /// in your type's `==` operator implementation. Call `hasher.combine(_:)`
    /// with each of these components.
    ///
    /// - Important: In your implementation of `hash(into:)`,
    ///   don't call `finalize()` on the `hasher` instance provided,
    ///   or replace it with a different instance.
    ///   Doing so may become a compile-time error in the future.
    ///
    /// - Parameter hasher: The hasher to use when combining the components
    ///   of this instance.
    public func hash(into hasher: inout Hasher)

    /// The hash value.
    ///
    /// Hash values are not guaranteed to be equal across different executions of
    /// your program. Do not save hash values to use during a future execution.
    ///
    /// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
    ///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
    ///   The compiler provides an implementation for `hashValue` for you.
    public var hashValue: Int { get }
}
enum

Event

NewmacOS
public enum Event : Sendable

Events emitted during a USD preview session

Declaration
public enum Event : Sendable {

    /// The USD animation timecode has changed
    case timeChanged(TimeInterval)

    /// The USD's animation playback state has changed
    case playbackStateChanged(isPlaying: Bool)

    /// Session error (editing read-only stage, etc.)
    case error(USDPreviewSession.Error)
}
enum

OptimizationParameters

NewmacOS
public enum OptimizationParameters : Sendable, CustomStringConvertible
Declaration
public enum OptimizationParameters : Sendable, CustomStringConvertible {

    /// The USD stage is used as-is with no optimization.
    case unmodified

    /// Allows the stage to analyzed for the given `OptimizationSteps` preferences and have those prefences applied.
    case processed(USDPreviewSession.OptimizationSteps)

    /// A textual representation of this instance.
    ///
    /// Calling this property directly is discouraged. Instead, convert an
    /// instance of any type to a string by using the `String(describing:)`
    /// initializer. This initializer works with any type, and uses the custom
    /// `description` property for types that conform to
    /// `CustomStringConvertible`:
    ///
    ///     struct Point: CustomStringConvertible {
    ///         let x: Int, y: Int
    ///
    ///         var description: String {
    ///             return "(\(x), \(y))"
    ///         }
    ///     }
    ///
    ///     let p = Point(x: 21, y: 30)
    ///     let s = String(describing: p)
    ///     print(s)
    ///     // Prints "(21, 30)"
    ///
    /// The conversion of `p` to a string in the assignment to `s` uses the
    /// `Point` type's `description` property.
    public var description: String { get }
}
struct

OptimizationSteps

NewmacOS
public struct OptimizationSteps : OptionSet, Sendable

A set of optimization steps to apply to a USD stage before previewing on a device.

Declaration
public struct OptimizationSteps : OptionSet, Sendable {

    /// The corresponding value of the raw type.
    ///
    /// A new instance initialized with `rawValue` will be equivalent to this
    /// instance. For example:
    ///
    ///     enum PaperSize: String {
    ///         case A4, A5, Letter, Legal
    ///     }
    ///
    ///     let selectedSize = PaperSize.Letter
    ///     print(selectedSize.rawValue)
    ///     // Prints "Letter"
    ///
    ///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
    ///     // Prints "true"
    public let rawValue: Int

    /// Creates a new option set from the given raw value.
    ///
    /// This initializer always succeeds, even if the value passed as `rawValue`
    /// exceeds the static properties declared as part of the option set. This
    /// example creates an instance of `ShippingOptions` with a raw value beyond
    /// the highest element, with a bit mask that effectively contains all the
    /// declared static members.
    ///
    ///     let extraOptions = ShippingOptions(rawValue: 255)
    ///     print(extraOptions.isStrictSuperset(of: .all))
    ///     // Prints "true"
    ///
    /// - Parameter rawValue: The raw value of the option set to create. Each bit
    ///   of `rawValue` potentially represents an element of the option set,
    ///   though raw values may include bits that are not defined as distinct
    ///   values of the `OptionSet` type.
    public init(rawValue: Int)

    /// Allows the USD stage to be analyzed and potentially simplified or replaced with a proxy before previewing on a device.
    /// The USD analysis decides at runtime whether the stage can be passed as-is, simplified in place, or swapped for a lower-fidelity proxy based on scene complexity and session capabilities.
    public static let optimized: USDPreviewSession.OptimizationSteps

    /// Allows the USD stage's textures and meshes to be compressed before previewing on a device.
    /// Reduces the transmission file size of the USD stage by compressing textures and meshes to
    /// minimize the data sent, and is only applied when the stage exceeds the compression threshold.
    /// Can be combined with `.optimized` — compression runs after the `.optimized` optimization step
    /// on the resulting stage.
    public static let compressed: USDPreviewSession.OptimizationSteps

    /// The type of the elements of an array literal.
    @available(macOS 27.0, visionOS 27.0, *)
    public typealias ArrayLiteralElement = USDPreviewSession.OptimizationSteps

    /// The element type of the option set.
    ///
    /// To inherit all the default implementations from the `OptionSet` protocol,
    /// the `Element` type must be `Self`, the default.
    @available(macOS 27.0, visionOS 27.0, *)
    public typealias Element = USDPreviewSession.OptimizationSteps

    /// The raw type that can be used to represent all values of the conforming
    /// type.
    ///
    /// Every distinct value of the conforming type has a corresponding unique
    /// value of the `RawValue` type, but there may be values of the `RawValue`
    /// type that don't have a corresponding value of the conforming type.
    @available(macOS 27.0, visionOS 27.0, *)
    public typealias RawValue = Int
}
struct

SpatialPreviewDevicePicker

NewmacOS
public struct SpatialPreviewDevicePicker : View

Presents nearby companion devices and allows the user to make a selection.

Declaration
@MainActor @preconcurrency public struct SpatialPreviewDevicePicker : View {

    /// Creates a device picker.
    ///
    /// - Parameters:
    ///   - isPresented: A binding to a Boolean that determines whether the picker view is displayed
    ///   - onSelect: When a device is selected the `SpatialPreviewEndpoint` for that device will be returned.
    @MainActor @preconcurrency public init(isPresented: Binding<Bool>, onSelect: @escaping (SpatialPreviewEndpoint) -> Void)

    /// The content and behavior of the view.
    ///
    /// When you implement a custom view, you must implement a computed
    /// `body` property to provide the content for your view. Return a view
    /// that's composed of built-in views that SwiftUI provides, plus other
    /// composite views that you've already defined:
    ///
    ///     struct MyView: View {
    ///         var body: some View {
    ///             Text("Hello, World!")
    ///         }
    ///     }
    ///
    /// For more information about composing views and a view hierarchy,
    /// see <doc:Declaring-a-Custom-View>.
    @MainActor @preconcurrency public var body: some View { get }

    /// The type of view representing the body of this view.
    ///
    /// When you create a custom view, Swift infers this type from your
    /// implementation of the required ``View/body-swift.property`` property.
    @available(macOS 27.0, *)
    @available(visionOS, unavailable)
    public typealias Body = some View
}
extension

SpatialPreviewDevicePicker

NewmacOS
extension SpatialPreviewDevicePicker : Sendable
Declaration
extension SpatialPreviewDevicePicker : Sendable {
}
struct

SpatialPreviewEndpoint

NewmacOS
public struct SpatialPreviewEndpoint : Hashable, Sendable, Codable, CustomStringConvertible, CustomReflectable

An endpoint representing a destination that that can be connected to

Declaration
public struct SpatialPreviewEndpoint : Hashable, Sendable, Codable, CustomStringConvertible, CustomReflectable {

    /// A textual representation of this instance.
    ///
    /// Calling this property directly is discouraged. Instead, convert an
    /// instance of any type to a string by using the `String(describing:)`
    /// initializer. This initializer works with any type, and uses the custom
    /// `description` property for types that conform to
    /// `CustomStringConvertible`:
    ///
    ///     struct Point: CustomStringConvertible {
    ///         let x: Int, y: Int
    ///
    ///         var description: String {
    ///             return "(\(x), \(y))"
    ///         }
    ///     }
    ///
    ///     let p = Point(x: 21, y: 30)
    ///     let s = String(describing: p)
    ///     print(s)
    ///     // Prints "(21, 30)"
    ///
    /// The conversion of `p` to a string in the assignment to `s` uses the
    /// `Point` type's `description` property.
    public var description: String { get }

    /// The custom mirror for this instance.
    ///
    /// If this type has value semantics, the mirror should be unaffected by
    /// subsequent mutations of the instance.
    public var customMirror: Mirror { get }

    /// Returns a Boolean value indicating whether two values are equal.
    ///
    /// Equality is the inverse of inequality. For any values `a` and `b`,
    /// `a == b` implies that `a != b` is `false`.
    ///
    /// - Parameters:
    ///   - lhs: A value to compare.
    ///   - rhs: Another value to compare.
    public static func == (a: SpatialPreviewEndpoint, b: SpatialPreviewEndpoint) -> Bool

    /// Encodes this value into the given encoder.
    ///
    /// If the value fails to encode anything, `encoder` will encode an empty
    /// keyed container in its place.
    ///
    /// This function throws an error if any values are invalid for the given
    /// encoder's format.
    ///
    /// - Parameter encoder: The encoder to write data to.
    public func encode(to encoder: any Encoder) throws

    /// Hashes the essential components of this value by feeding them into the
    /// given hasher.
    ///
    /// Implement this method to conform to the `Hashable` protocol. The
    /// components used for hashing must be the same as the components compared
    /// in your type's `==` operator implementation. Call `hasher.combine(_:)`
    /// with each of these components.
    ///
    /// - Important: In your implementation of `hash(into:)`,
    ///   don't call `finalize()` on the `hasher` instance provided,
    ///   or replace it with a different instance.
    ///   Doing so may become a compile-time error in the future.
    ///
    /// - Parameter hasher: The hasher to use when combining the components
    ///   of this instance.
    public func hash(into hasher: inout Hasher)

    /// The hash value.
    ///
    /// Hash values are not guaranteed to be equal across different executions of
    /// your program. Do not save hash values to use during a future execution.
    ///
    /// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
    ///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
    ///   The compiler provides an implementation for `hashValue` for you.
    public var hashValue: Int { get }

Truncated.

protocol

SpatialPreviewSession

NewmacOS
public protocol SpatialPreviewSession : AnyObject, Observable

A session that manages the lifecycle and connection state of a spatial preview on a visionOS device.

Declaration
public protocol SpatialPreviewSession : AnyObject, Observable {

    /// Reports the progress of the session
    var progress: ProgressReporter { get }

    /// Gracefully close the session
    nonisolated(nonsending) func close() async throws

    /// Can observe this state
    var state: SpatialPreviewSessionState { get }
}
enum

SpatialPreviewSessionError

NewmacOS
public enum SpatialPreviewSessionError : Error, Sendable
Declaration
public enum SpatialPreviewSessionError : Error, Sendable {

    case invalidated

    /// Use of an invalid spatial preview device
    case invalidSpatialPreviewEndpoint

    /// Reached a maximum number of sessions for the receiving device
    case tooManySessions

    /// Returns a Boolean value indicating whether two values are equal.
    ///
    /// Equality is the inverse of inequality. For any values `a` and `b`,
    /// `a == b` implies that `a != b` is `false`.
    ///
    /// - Parameters:
    ///   - lhs: A value to compare.
    ///   - rhs: Another value to compare.
    public static func == (a: SpatialPreviewSessionError, b: SpatialPreviewSessionError) -> Bool

    /// Hashes the essential components of this value by feeding them into the
    /// given hasher.
    ///
    /// Implement this method to conform to the `Hashable` protocol. The
    /// components used for hashing must be the same as the components compared
    /// in your type's `==` operator implementation. Call `hasher.combine(_:)`
    /// with each of these components.
    ///
    /// - Important: In your implementation of `hash(into:)`,
    ///   don't call `finalize()` on the `hasher` instance provided,
    ///   or replace it with a different instance.
    ///   Doing so may become a compile-time error in the future.
    ///
    /// - Parameter hasher: The hasher to use when combining the components
    ///   of this instance.
    public func hash(into hasher: inout Hasher)

    /// The hash value.
    ///
    /// Hash values are not guaranteed to be equal across different executions of
    /// your program. Do not save hash values to use during a future execution.
    ///
    /// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
    ///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
    ///   The compiler provides an implementation for `hashValue` for you.
    public var hashValue: Int { get }
}
extension

SpatialPreviewSessionError

NewmacOS
extension SpatialPreviewSessionError : Equatable
Declaration
extension SpatialPreviewSessionError : Equatable {
}
extension

SpatialPreviewSessionError

NewmacOS
extension SpatialPreviewSessionError : Hashable
Declaration
extension SpatialPreviewSessionError : Hashable {
}
enum

SpatialPreviewSessionState

NewmacOS
public enum SpatialPreviewSessionState : Sendable, Hashable

Indicates the state of the session and the health of the underlying connection.

Declaration
public enum SpatialPreviewSessionState : Sendable, Hashable {

    /// The session has been created, but not started.
    case waiting

    /// The session is actively connected
    case connected

    /// The session connection has been interrupted, but may resume.
    case interrupted

    /// The sesion has been invalidated and is no longer available.
    case invalidated

    /// Returns a Boolean value indicating whether two values are equal.
    ///
    /// Equality is the inverse of inequality. For any values `a` and `b`,
    /// `a == b` implies that `a != b` is `false`.
    ///
    /// - Parameters:
    ///   - lhs: A value to compare.
    ///   - rhs: Another value to compare.
    public static func == (a: SpatialPreviewSessionState, b: SpatialPreviewSessionState) -> Bool

    /// Hashes the essential components of this value by feeding them into the
    /// given hasher.
    ///
    /// Implement this method to conform to the `Hashable` protocol. The
    /// components used for hashing must be the same as the components compared
    /// in your type's `==` operator implementation. Call `hasher.combine(_:)`
    /// with each of these components.
    ///
    /// - Important: In your implementation of `hash(into:)`,
    ///   don't call `finalize()` on the `hasher` instance provided,
    ///   or replace it with a different instance.
    ///   Doing so may become a compile-time error in the future.
    ///
    /// - Parameter hasher: The hasher to use when combining the components
    ///   of this instance.
    public func hash(into hasher: inout Hasher)

    /// The hash value.
    ///
    /// Hash values are not guaranteed to be equal across different executions of
    /// your program. Do not save hash values to use during a future execution.
    ///
    /// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
    ///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
    ///   The compiler provides an implementation for `hashValue` for you.
    public var hashValue: Int { get }
}
extension

SpatialPreviewSessionState

NewmacOS
extension SpatialPreviewSessionState
Declaration
extension SpatialPreviewSessionState {

    public var isInvalidated: Bool { get }
}
extension

USDPreviewSession

NewmacOS
extension USDPreviewSession : Observable
Declaration
extension USDPreviewSession : Observable {
}
extension

USDPreviewSession

NewmacOS
extension USDPreviewSession : @unchecked Sendable
Declaration
extension USDPreviewSession : @unchecked Sendable {
}
extension

USDPreviewSession

NewmacOS
extension USDPreviewSession
Declaration
extension USDPreviewSession {

    final public var time: TimeInterval

    final public var isPlaying: Bool
}
extension

USDPreviewSession.Error

NewmacOS
extension USDPreviewSession.Error : Equatable
Declaration
extension USDPreviewSession.Error : Equatable {
}
extension

USDPreviewSession.Error

NewmacOS
extension USDPreviewSession.Error : Hashable
Declaration
extension USDPreviewSession.Error : Hashable {
}
typealias

OptimizationSteps.ArrayLiteralElement

NewmacOS
public typealias ArrayLiteralElement = USDPreviewSession.OptimizationSteps

The type of the elements of an array literal.

typealias

OptimizationSteps.Element

NewmacOS
public typealias Element = USDPreviewSession.OptimizationSteps

The element type of the option set.

To inherit all the default implementations from the OptionSet protocol, the Element type must be Self, the default.

typealias

OptimizationSteps.RawValue

NewmacOS
public typealias RawValue = Int

The raw type that can be used to represent all values of the conforming type.

Every distinct value of the conforming type has a corresponding unique value of the RawValue type, but there may be values of the RawValue type that don't have a corresponding value of the conforming type.

typealias

SpatialPreviewDevicePicker.Body

NewmacOS
public typealias Body = some View

The type of view representing the body of this view.

When you create a custom view, Swift infers this type from your implementation of the required body-swift.property property.

typealias

USDPreviewSession.SpatialViewerOptions.ArrayLiteralElement

NewmacOS
public typealias ArrayLiteralElement = USDPreviewSession.SpatialViewerOptions

The type of the elements of an array literal.

typealias

USDPreviewSession.SpatialViewerOptions.Element

NewmacOS
public typealias Element = USDPreviewSession.SpatialViewerOptions

The element type of the option set.

To inherit all the default implementations from the OptionSet protocol, the Element type must be Self, the default.

typealias

USDPreviewSession.SpatialViewerOptions.RawValue

NewmacOS
public typealias RawValue = Int

The raw type that can be used to represent all values of the conforming type.

Every distinct value of the conforming type has a corresponding unique value of the RawValue type, but there may be values of the RawValue type that don't have a corresponding value of the conforming type.

No APIs match your filter.

← More in Spatial, 3D & RealityKit