RealityKit custom component: `has()` returns `true` but typed subscript returns `nil` in SwiftPM test runner

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) returns true
  • entity.components[ReproComponent.self] returns nil

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 test works 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 test workaround

Feedback ID: FB22099519

Environment: macOS 15.5, Xcode 16.4, Swift 6.1

To clarify i'm on macOS 26.3.1 (a) the reported environment was wrong, but I cannot edit the OP.

RealityKit custom component: `has()` returns `true` but typed subscript returns `nil` in SwiftPM test runner
 
 
Q