ConnectedSpatialEndpointObserver
NewmacOSextension ConnectedSpatialEndpointObserver : nonisolated ObservableDeclaration
extension ConnectedSpatialEndpointObserver : nonisolated Observable {
}What's New / Spatial, 3D & RealityKit
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.
ConnectedSpatialEndpointObserverextension ConnectedSpatialEndpointObserver : nonisolated Observableextension ConnectedSpatialEndpointObserver : nonisolated Observable {
}ConnectedSpatialEndpointObserverextension ConnectedSpatialEndpointObserver : Sendableextension ConnectedSpatialEndpointObserver : Sendable {
}DocumentPreviewSessionextension DocumentPreviewSession : Observableextension DocumentPreviewSession : Observable {
}DocumentPreviewSessionextension DocumentPreviewSession : Sendableextension DocumentPreviewSession : Sendable {
}Errorpublic enum Error : ErrorErrors that can occur during a USD preview session
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 }
}Eventpublic enum Event : SendableEvents emitted during a USD preview session
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)
}OptimizationParameterspublic enum OptimizationParameters : Sendable, CustomStringConvertiblepublic 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 }
}OptimizationStepspublic struct OptimizationSteps : OptionSet, SendableA set of optimization steps to apply to a USD stage before previewing on a device.
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
}SpatialPreviewDevicePickerpublic struct SpatialPreviewDevicePicker : ViewPresents nearby companion devices and allows the user to make a selection.
@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
}SpatialPreviewDevicePickerextension SpatialPreviewDevicePicker : Sendableextension SpatialPreviewDevicePicker : Sendable {
}SpatialPreviewEndpointpublic struct SpatialPreviewEndpoint : Hashable, Sendable, Codable, CustomStringConvertible, CustomReflectableAn endpoint representing a destination that that can be connected to
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.
SpatialPreviewSessionpublic protocol SpatialPreviewSession : AnyObject, ObservableA session that manages the lifecycle and connection state of a spatial preview on a visionOS device.
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 }
}SpatialPreviewSessionErrorpublic enum SpatialPreviewSessionError : Error, Sendablepublic 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 }
}SpatialPreviewSessionErrorextension SpatialPreviewSessionError : Equatableextension SpatialPreviewSessionError : Equatable {
}SpatialPreviewSessionErrorextension SpatialPreviewSessionError : Hashableextension SpatialPreviewSessionError : Hashable {
}SpatialPreviewSessionStatepublic enum SpatialPreviewSessionState : Sendable, HashableIndicates the state of the session and the health of the underlying connection.
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 }
}SpatialPreviewSessionStateextension SpatialPreviewSessionStateextension SpatialPreviewSessionState {
public var isInvalidated: Bool { get }
}USDPreviewSessionextension USDPreviewSession : Observableextension USDPreviewSession : Observable {
}USDPreviewSessionextension USDPreviewSession : @unchecked Sendableextension USDPreviewSession : @unchecked Sendable {
}USDPreviewSessionextension USDPreviewSessionextension USDPreviewSession {
final public var time: TimeInterval
final public var isPlaying: Bool
}USDPreviewSession.Errorextension USDPreviewSession.Error : Equatableextension USDPreviewSession.Error : Equatable {
}USDPreviewSession.Errorextension USDPreviewSession.Error : Hashableextension USDPreviewSession.Error : Hashable {
}OptimizationSteps.ArrayLiteralElementpublic typealias ArrayLiteralElement = USDPreviewSession.OptimizationStepsThe type of the elements of an array literal.
OptimizationSteps.Elementpublic typealias Element = USDPreviewSession.OptimizationStepsThe element type of the option set.
To inherit all the default implementations from the OptionSet protocol, the Element type must be Self, the default.
OptimizationSteps.RawValuepublic typealias RawValue = IntThe 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.
SpatialPreviewDevicePicker.Bodypublic typealias Body = some ViewThe 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.
USDPreviewSession.SpatialViewerOptions.ArrayLiteralElementpublic typealias ArrayLiteralElement = USDPreviewSession.SpatialViewerOptionsThe type of the elements of an array literal.
USDPreviewSession.SpatialViewerOptions.Elementpublic typealias Element = USDPreviewSession.SpatialViewerOptionsThe element type of the option set.
To inherit all the default implementations from the OptionSet protocol, the Element type must be Self, the default.
USDPreviewSession.SpatialViewerOptions.RawValuepublic typealias RawValue = IntThe 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.