The Accepted answer is fine and here is another solution :
you can check for the availability of depth data from LiDAR, we need to check whether our device supports this sensor
and enable its flag ‘.sceneDepth’ in ARConfiguration.
Use This Func
func setupARConfiguration() -> ARConfiguration{
let configuration = ARWorldTrackingConfiguration()
// add specific configurations
if ARWorldTrackingConfiguration.supportsFrameSemantics(.sceneDepth) {
configuration.frameSemantics = .sceneDepth
}else {
print("Device is not support lidar sensor")
}
return configuration
}
from Apple Docs :
Call this function before attempting to enable a frame semantic on your app's configuration. For example, if you call supportsFrameSemantic(.sceneDepth) on ARWorldTrackingConfiguration, the function returns true on devices that support the LiDAR scanner's depth buffer.
Ref :
https://developer.apple.com/documentation/arkit/arconfiguration/3089122-supportsframesemantics