I created a .reality file which i exported from Reality Composer and added to the project.
The code:
class ViewController: UIViewController {
@IBOutlet var arView: ARView!
override func viewDidLoad() {
super.viewDidLoad()
if let anchor = try? Entity.loadAnchor(named: "ARAnchorTestFile") {
arView.scene.addAnchor(anchor)
}
}
}
On devices with iOS version 13.5 or higher the app crash when the anchoring is triggered and the 3D model should be displayed.
The error:
Thread 1: EXC_BAD_ACCESS (code=1, address=0x40)
The entire project has been uploaded to this repo: https://github.com/evjand/ARAnchorTest
UPDATE: After filing a bug repport to Apple it seems like they have fixed it in the iOS 14 beta.
Seems there's a bug when reading .reality
file. Use .rcproject
format instead. It works.
if let anchor = try? Entity.loadAnchor(named: "AR") {
arView.scene.addAnchor(anchor)
print(anchor)
}