iOS Simulator: "Cannot find ObjectCaptureSession in scope"

Hello guys,

I am trying to get ObjectCapturing up and running. Ob the physical device side everything works great (except sind the Framework update which needed code adjustments and still crashes while reconstructing).

I marked every class with @available(iOS 17.0, *) and the projects also runs on devices with iOS 16.

The problem is, that when i want to build the project on the simulator (i know it wont work there but the scan is part of a bigger App and I need to keep simulator functionality for testing other features), the build fails because he cant find the ObjectCaptureSession.

Is there any known way to fix this?

Thanks in advance!

Kind Regards

Replies

I comment out any views and sessions and methods with object capture with:

#if targetEnvironment(simulator)
#endif

It's tedious but it works.

  • The Object Capture code is not included in simulator, so will need to be conditioned out of your simulator-targeted code as shown above.

Add a Comment

You can use this to compile the code only for real devices. You need to put the if statement around the whole ObjectCapture code.

#if arch(arm64) || arch(x86_64)
// Code that should not be compiled for simulator devices
#endif

Thanks guys!

I got it to work with

#if targetEnvironment(simulator)

#endif