A Swift Package for using OpenUSD, Pixar's Universal Scene Description
Before you can start using SwiftUsd, you need to add it as a dependency to your Xcode project or Swift Package, and then configure a few build settings.
- To use SwiftUsd in an Xcode project, select File > Add Package Dependency, and enter
https://github.com/apple/SwiftUsdas the URL. - In the build settings for your target, set
C++ and Objective-C InteroperabilitytoC++ / Objective-C++(SWIFT_OBJC_INTEROP_MODE=objcxx). - In the build settings for your target, set
C++ Language DialecttoGNU++17 [-std=gnu++17](CLANG_CXX_LANGUAGE_STANDARD=gnu++17).
- To use SwiftUsd in a Swift Package, first add it as a dependency:
dependencies:[.package(url:"https://github.com/apple/SwiftUsd", from:"8.1.0"),]- Then enable Swift-Cxx interoperability on your Swift targets:
.target(name:"MyTarget",
dependencies:[.product(name:"OpenUSD",package:"SwiftUsd")],
swiftSettings:[.interoperabilityMode(.Cxx)]),- Then set the C++ language standard to GNU++17:
letpackage=Package(
name:"MyPackage",
targets:[...],
cxxLanguageStandard:.gnucxx17
)Once you've added SwiftUsd as a package depedency to your Xcode project or Swift Package, enabled Swift-Cxx interop, and set the C++ version to GNU++17, you're ready to start using SwiftUsd:
import OpenUSD
func makeHelloWorldString()->String{letstage=Overlay.Dereference(pxr.UsdStage.CreateInMemory())
stage.DefinePrim("/hello",.UsdGeomTokens.Xform)
stage.DefinePrim("/hello/world",.UsdGeomTokens.Sphere)return stage.ExportToString()??"nil"}- SwiftUsd-Tests, unit tests for SwiftUsd
- SwiftUsd-ast-answerer, code generation tool for SwiftUsd
See the online documentation here.
Alternatively, open the included SwiftUsd.doccarchive in Xcode for local viewing.