How to get Lux by SRAmbientLightSample ?

After iOS 14, it seems to get Lux by SRAmbientLightSample.

https://developer.apple.com/documentation/sensorkit/srambientlightsample

But when I use this code:


import SensorKit

let lightSample = SRAmbientLightSample()

let lux = lightSample.lux


It always crashes at "let lux = lightSample.lux"

I can find any usages from this document page, and also stack overflow.

Please help to know, how to get Lux by SRAmbientLightSample ?

Thanks.

Using the SensorKit framework requires a special entitlement. Without this entitlement it is not possible to run an app using SensorKit functionality.

Apple grants the entitlement only for research studies. If you're interested in accessing SensorKit data for your study, submit a research proposal and request the entitlement. For more information, see Accessing SensorKit Data https://www.researchandcare.org/resources/accessing-sensorkit-data/

More information can be found here: https://developer.apple.com/documentation/sensorkit/configuring_your_project_for_sensor_reading

How to get Lux by SRAmbientLightSample ?
 
 
Q