Object anchor not working with ARKit in iOS

With WWDC 24, I was excited to see that apple is bringing their APIs from Vision OS to iOS.

I tried using the Object Anchoring component in Reality Composer Pro. Which this works with a Vision Pro, it looks like the entity will spawn at origin if we run the same on iOS and the object anchoring doesn't seem to work.

Is this intended? Below is how I'm doing this.

I added an Anchoring component and added the .referenceObject file I trained using CreateML.

This is the code I'm using to load this scene in.

//  GrootView.swift
//  ARTest-New
//
//  Created by Sravan Karuturi on 6/10/24.
//

import SwiftUI
import RealityKit
import Box

struct GrootView: View {
    
    @StateObject private var grootVM = GrootViewModel()
    @State private var ent: Entity? = nil
    
    @State var anchor: Entity? = nil
    @State var wallAnchor: Entity? = nil
    @State var floorAnchor: Entity? = nil
    
    var body: some View {
        
        RealityView{ content in
            
#if os(iOS)
            await content.setupWorldTracking()
            content.camera = .worldTracking
#endif
            
            ent = try? await Entity(named: "Box", in: boxBundle)
            print(ent?.children)
            
            anchor = ent?.findEntity(named: "ObjectAnchor")
            wallAnchor = ent?.findEntity(named: "WallAnchor")
            floorAnchor = ent?.findEntity(named: "FloorAnchor")
            
            let updateSum = content.subscribe(to: SceneEvents.Update.self){ event in
                
                if let anc = anchor, anc.isAnchored {
                    print("Found Item")
                }
                
                if let anc = floorAnchor, anc.isAnchored {
                    print("Found Floor")
                }
                
                if let anc = wallAnchor, anc.isAnchored {
                    print("Wall Anchor")
                }
                
            }
            
            content.add(ent!)
            
        }
        
    }
}

#Preview {
    GrootView()
}

While, something similar seems to work on visionOS, the same doesn't seem to work with iOS.

When I run this app, we see all the children and the Found Item is printed constantly even when we don't have the item in the scene.

Not really sure if this is just not supported yet on iOS ( I really hope that's not the case ) or if I messed up something somehow

Answered by Vision Pro Engineer in 790782022

Hello,

The feature you are trying is not supported for visionOS. The Object API's for visionOS vs iOS are not the same. So the project you show above will only work on visionOS and you will have to use the previous api's for iOS with ARKit.

Hello,

The feature you are trying is not supported for visionOS. The Object API's for visionOS vs iOS are not the same. So the project you show above will only work on visionOS and you will have to use the previous api's for iOS with ARKit.

Hi

Object anchor not working with ARKit in iOS
 
 
Q