I understand that the sample code is not yet available.
Thank you in advance.
Post
Replies
Boosts
Views
Activity
So it seems the ObjectCaptureSession is not available on the simulator, so you need to attach a device that has LiDAR and runs iOS 17 to get rid of this issue.
This was fixed by attaching a device with iOS 17
In my case it's an iPad with Lidar and iOS 17 installed.
I read on a different comment that ObjectCaptureSession is not available on the simulator.
It hasn't been published yet, just wait a few days.
They are working hard on this.
Hello! ObjectCaptureSession and ObjectCaptureView are NOT available on simulators yet.
You need a real device attached to xCode to get rid of this error.
I fixed this by running startSession outside the body.
That was causing the issue.
@MainActor func startSession() {
guard #available(iOS 17.0, *) else { return }
do {
let session = ObjectCaptureSession()
var configuration = ObjectCaptureSession.Configuration()
configuration.checkpointDirectory = getDocumentsDir().appendingPathComponent("Snapshots/")
try session.start(imagesDirectory: getDocumentsDir().appendingPathComponent("Images/"), configuration: configuration)
self.session = session
} catch {
sessionError = error
}
}
Also added:
.onAppear {
startSession()
}
after
.environment(\.colorScheme, .dark)
Here is the final part of the code inside the ZStack
if let session = session {
ObjectCaptureView(session: session)
if case .ready = session.state {
Button(action: {
session.startDetecting()
}) {
Text("Continue")
.foregroundColor(.white)
.padding()
.background(Color.blue)
.cornerRadius(10)
}
} else if case .detecting = session.state {
Button(action: {
session.startCapturing()
}) {
Text("Start Capture")
.foregroundColor(.white)
.padding()
.background(Color.blue)
.cornerRadius(10)
}
}
} else if let error = sessionError {
Text("Failed to start ObjectCaptureSession: \(error.localizedDescription)")
} else {
Text("Initializing...")
}
As you can see I changed the CreateButton part because it was also not defined in the video.
So I went back to the old way of creating buttons.
Hope this helps you move fwd
Now can anyone please explain how to disable the Metal API Validation?
I tried switching this to "Disabled" or "OpenGL ES"
Cleaned the Build folder, built again.
But I am still getting the same error.
[Deleted]