Swift test + RealityKit custom component decode mismatch (has == true, typed decode == nil) — minimal repro

Hi all,

I’m seeing what looks like a mismatch specifically when running tests via SwiftPM CLI (swift test), and I’m not sure whether this should be tracked as SwiftPM, Swift Testing, or RealityKit.

I made a minimal repro repo:
https://github.com/mesqueeb/swiftpm-realitykit-custom-component-repro

It’s intentionally tiny:

  • one custom RealityKit component (ReproComponent)
  • one tiny local USDA file with that custom component attached
  • one test that loads the entity and checks raw-vs-typed component access

Repro command:

swift test --filter componentsPresentButNotDecodableInSwiftTest

Observed:

  • entity.components.has(ReproComponent.self) == true
  • entity.components[ReproComponent.self] == nil
  • test reports raw=1, decoded=0

Expected:

  • if has(...) is true for that registered custom component, typed lookup should decode and return non-nil.

In my main project, this difference affects E2E behavior, and running via xcodebuild test appears to behave differently from swift test.

Question:

  • Is this best reported/triaged from the SwiftPM side, or should I file/move this directly as a RealityKit issue (Feedback Assistant)?
  • Any known constraints around custom component decoding in SwiftPM test runtime?

Thanks for any guidance.

I don't see anything here that suggests a bug in Swift Testing. While it may be a bug in SwiftPM (I'm not an expert on that part of it) I would start by filing feedback against RealityKit with Apple about it. If it does turn out to be a SwiftPM issue, they can send the bug report along.

1 Like

Submitted as FB22099519.
I never know why people post these though, as I'm pretty sure it's not possible to make the ticket "public". :thinking:

It helps other people file similar reports, they can then reference this number.

1 Like