RealityView in Xcode 15.0 beta 8 gives error - 'init(make:update:attachments:)' is unavailable in visionOS

My code was working in beta 7 but since I updated I'm getting the following error when trying to init a RealityView 'init(make:update:attachments:)' is unavailable in visionOS

I'm using:

RealityView { content, attachments in
    // Code ...
} update: { content, attachments in
    // Code ...
} attachments: {
    // Code ... 
}
Answered by warpling in 763289022

As far as I can tell this big change went undocumented but the way attachments work completely changed:

Old:

RealityView { content, attachments in
    content.add(Entity())
} attachments: {
    Text("Hello")
        .tag("h1")
}

New:

RealityView { content, attachments in
    content.add(Entity())
} attachments: {
    Attachment(id: "h1") {
        Text("Hello")
    }
}

Definitely an improvement but I hope it get’s added to the change log soon! Or at least get’s a helpful warning in the next Xcode! (edited)

Accepted Answer

As far as I can tell this big change went undocumented but the way attachments work completely changed:

Old:

RealityView { content, attachments in
    content.add(Entity())
} attachments: {
    Text("Hello")
        .tag("h1")
}

New:

RealityView { content, attachments in
    content.add(Entity())
} attachments: {
    Attachment(id: "h1") {
        Text("Hello")
    }
}

Definitely an improvement but I hope it get’s added to the change log soon! Or at least get’s a helpful warning in the next Xcode! (edited)

13

Yes! Wrapping my attachments in Attachment(id:){} worked. I would have never guessed this would have been the solution with that terrible error message so thanks for your help.

Thanks for mentioning the update in RealityView, guess this was missed out in the latet Release Notes

Same here! Thanks warpling for your advise.

With this update, Button and Toggle attachments oftentimes don't fire on first load in an immersive space. They always seem to work when the same immersive space is loaded again. Smells like a race condition. I can reproduce this with Xcode's visionOS template project.

Apple should clearly communicate these changes. I just got the error message: "attachments" not available on visionOS. What the ...?

RealityView in Xcode 15.0 beta 8 gives error - 'init(make:update:attachments:)' is unavailable in visionOS
 
 
Q