Standard code gives an error

I chose to use the standard code created by selecting "Augmented Reality App" in Xcode and using it.

But I get the error Use of unresolved identifier 'Experience'

How can I solve this?


ARView.swift

import SwiftUI
import RealityKit

struct ARViewContainer: UIViewRepresentable {
   
    func makeUIView(context: Context) -> ARView {
       
        let arView = ARView(frame: .zero)
       
        // Load the "Box" scene from the "Experience" Reality File

        let boxAnchor = try! Experience.loadBox()
       
        // Add the box anchor to the scene
        arView.scene.anchors.append(boxAnchor)
       
        return arView
       
    }
   
    func updateUIView(_ uiView: ARView, context: Context) {}
   
}


ARKitView.swift

import SwiftUI

struct ARKitView: View {
    var body: some View {
        return ARViewContainer().edgesIgnoringSafeArea(.all)
    }
}

struct ARKitView_Previews: PreviewProvider {
    static var previews: some View {
        ARKitView()
    }
}


Experience.rcproject

「Box」Seen

I receive the same error as well.

It seems like Xcode doesn't recognize the Experience.swift file from the Experience.rcproject file.


There were times where I was somehow able to see the Experience.swift as I was toggling through the navigator pane.

But I couldn't access it after a couple times, and gave me the same error.


Apple, is this a version error?

Update: I just went ahead and built&run the app.

It worked. I guess it needs to be built once for Xcode to recognize the .swift file.

Hopefully it works with you.

CLICKING ON the Experience.rcproject file, and waiting a fraction of a sec for the 3d cube to load, solved it for me.
(Just building the project, or cleaning & building it, didn't work).
Standard code gives an error
 
 
Q