AnchorEntity from ARAnchor bug?

I am running into a strange bug where the exact same code compiles fine in one project but generates a compiler error in another project.

In particular, I am trying to create an AnchorEnity from an ARAnchor.

func addModelTo(anchor: ARAnchor)
{
    let entityAnchor = AnchorEntity(anchor: anchor)
    ...
}

The compiler error message is not even consistent. Sometimes I get a single error message:

Cannot convert value of type 'ARAnchor' to expected argument type 'AnchoringComponent.Target'

Other times I get an error with two possible issues:

No exact matches in call to initializer

Candidate '() -> AnchorEntity' requires 0 arguments, but 1 was provided (RealityFoundation.AnchorEntity)

Candidate expects value of type 'AnchoringComponent.Target' for parameter #1 (got '(anchor: ARAnchor)')

I'm trying to track down why this sometimes causes an error and sometimes it does not.

Any pointers?

Answered by Todd2 in 735357022

Figured it out!

I needed to plug-in my phone and build for the actual device (as opposed to the simulator)

Building for Any iOS Device (arm64) works too.

Accepted Answer

Figured it out!

I needed to plug-in my phone and build for the actual device (as opposed to the simulator)

Building for Any iOS Device (arm64) works too.

AnchorEntity from ARAnchor bug?
 
 
Q