Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

RealityKit Entity ComponentSet does not conform to Sequence?

Hello,

I'm trying to view the components of an Entity I'm creating in RealityKit by reading from a USDZ file. I have the following code snippet in my app.

if let appleEntity = try? Entity.loadModel(named: "apple_tile") {
    let c = appleEntity.components
    for comp in c { // <- compiler error here
        print(comp)
     }
}

The compiler error I'm receiving says "For-in loop requires 'Entity.ComponentSet' to conform to 'Sequence'". However, I thought this was the case, according to the documentation for Entity.ComponentSet?

Curious if anyone else has had this problem. Running XCode 15.4, and my Swift version is

xcrun swift -version
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: x86_64-apple-macosx14.0
Answered by Vision Pro Engineer in 829059022

Hi @dwkot ,

I think this is worth filing a feedback with a repro case at http://feedbackassistant.apple.com. That will help further diagnose what's going on here.

Thanks!

Hello @dwkot,

Your code compiles for me. I wonder if there is something confusing the compiler about what c is.

Hey there,

Thanks for checking that for me. It's encouraging to hear that it compiles. I renamed the variable c to something more unique, but the compilation bug described above persisted. I also did a clean build and tried restarting XCode, but the problem still persists. What's odd is that some of the other functionality for the Entity.ComponentSet, such as set() or removeAll() compiles with no issue. The compiler just doesn't see the Sequence conformance for the for-in loop.

Accepted Answer

Hi @dwkot ,

I think this is worth filing a feedback with a repro case at http://feedbackassistant.apple.com. That will help further diagnose what's going on here.

Thanks!

RealityKit Entity ComponentSet does not conform to Sequence?
 
 
Q