USDKit is a new first-class Swift framework introduced in iOS/macOS 27 that provides native USD scene loading, composition, editing, and export β including mesh and texture compression β with deep RealityKit and Spatial Preview integration.
β’ Developers can load, traverse, modify, and export full USD scenes entirely in Swift without bridging to C++ or third-party tools
β’ Built-in exportPackage API supports up to 90% mesh compression (via Alliance for Open Media codec) plus AVIF texture compression, shrinking assets ~7x
β’ Accessibility metadata (labels and descriptions on 3D prims) is standardized and directly supported, making spatial content inclusive out of the box
Demonstrates opening a USD stage, adding a referenced asset prim with a transform, attaching accessibility metadata, and exporting a compressed package β all using the new USDKit Swift API.
import USDKit
import Foundation
// 1. Open an existing USD stage from a file URL
let sceneURL = Bundle.main.url(forResource: "workbench", withExtension: "usdc")!
let stage = try USDStage.open(sceneURL)
// 2. Traverse the stage hierarchy to check for an existing prim
let existingPrim = stage.prim(at: "/World/Oscilloscope")
if existingPrim == nil {
print("Oscilloscope not found β adding it now.")
}
// 3. Define a new transform prim at the desired scene path
let transformPrim = stage.definePrim(
at: "/World/Oscilloscope",
typeName: "Xform"
)
// 4. Add a lightweight reference to an external asset layer
// (composition: no data is copied, updates to the source propagate automatically)
let assetURL = Bundle.main.url(forResource: "oscilloscope", withExtension: "usdz")!
transformPrim.addReference(assetURL)
// 5. Move the prim onto the workbench via a translate operation
let translateOp = transformPrim.addTransformOperation(type: .translate)
try translateOp.set(value: SIMD3<Double>(0.0, 0.92, 0.0))
// 6. Apply the USD AccessibilityAPI schema and author metadata
transformPrim.apply(schema: "AccessibilityAPI")
let labelAttr = transformPrim.createAttribute(
named: "accessibility:label",
typeName: .string
)
try labelAttr.set(value: "Vintage oscilloscope")
let descAttr = transformPrim.createAttribute(
named: "accessibility:description",
typeName: .string
)
try descAttr.set(value: "A vintage analog oscilloscope sitting on the workbench, displaying a sine wave on its green CRT screen.")
// 7. Export a compressed package (mesh ~90% smaller, textures via AVIF)
let outputURL = FileManager.default
.temporaryDirectory
.appendingPathComponent("workbench_compressed.usdz")
var options = USDExportOptions()
options.compressMeshes = true
options.compressTextures = true
try stage.exportPackage(to: outputURL, options: options)
print("Exported compressed package to: \(outputURL.path)")
USDKit does not expose all schema-specific attribute APIs directly β for custom or domain schemas (e.g., AccessibilityAPI) you must create attributes by name using the string constants from the USD specification. Compression options require the exportPackage API, not a plain file save. SwiftUSD via SPM remains available for cross-platform C++ pipelines where USDKit coverage is insufficient.
No special hardware required, though Spatial Preview live-sync features require a paired Vision Pro
More iOS 27 APIs land every week.
Get notified when new capabilities are published β no noise, just signal.