RealityKit, Attachments - not working

The simplest realityView (content, attachments in ... causes Contextual closure expects 1 argument but 2 were used in closure body. I have checked every example and i cannot understand why i get this error regardless of any content. Note: i have added Attachment(id: "test") to the attachment closure and get Attachment not is scope.

imported both realityKit and SwiftUI.

Hi @BrianMcDonald

Are you building for visionOS?

RealityKit attachments are only available in visionOS, and you will encounter the above error if you try building for a non-supported platform, such as iOS or macOS.

If you'd like us to consider adding the necessary functionality, please file an enhancement request using Feedback Assistant and post the FB number here.

Thanks!

It would be really nice if RealityView could be kept in sync for all platforms. ViewAttachmentComponents are a very useful addition and it is a shame that it is only available on VisionOS, and not iOS. Is there an easy way to add simple SwiftUI views to a RealityView in iOS? I know ViewAttachmentComponents are visionOS only, but can we achieve the same functionality by building Entities manually and somehow mapping SwiftUI views onto it? Is there sample code somewhere we could look at?

Thanks

RealityKit, Attachments - not working
 
 
Q