swift test (SwiftPM CLI) fails to decode RealityKit custom components from USD files, even though entity.components.has(MyComponent.self) returns true. Typed access via entity.components[MyComponent.self] returns nil.
This forces projects that use RealityKit custom components to use xcodebuild test exclusively.
Minimal repro: github.com/mesqueeb/swiftpm-realitykit-custom-component-repro
Repro steps
git clone https://github.com/mesqueeb/swiftpm-realitykit-custom-component-repro
cd swiftpm-realitykit-custom-component-repro
swift test --filter componentsPresentButNotDecodableInSwiftTest
Observed
- ✅
entity.components.has(ReproComponent.self)returnstrue - ❌
entity.components[ReproComponent.self]returnsnil
Expected
If has(...) returns true for a registered custom component, typed lookup should decode and return non-nil.
Notes
- Running the same test via
xcodebuild testworks correctly - The component is properly registered and the USDA file correctly references it
- This affects any project that relies on custom RealityKit components in tests — there is no
swift testworkaround
Feedback ID: FB22099519
Environment: macOS 15.5, Xcode 16.4, Swift 6.1