My app uses the barometric data from the CMAltimeter on iOS (iPhone). That has always worked just fine. But after installing iOS 17.4, it stopped working. Other apps that use barometric data also stopped working. So it appears to be a major fault in iOS 17.4.
Below is the (Swift) code used to test this. This code used to work fine with earlier versions of iOS, but in 17.4, the authorizationStatus() returns .restricted, and the handler is called with the error:
The operation couldn’t be completed. (CMErrorDomain error 105.)
This all indicates there is some authentication failure. I have logged bug report with Apple.
But I wonder if others experienced the same, and if there is some work-around/solution that makes barometric data available again.
if CMAltimeter.isRelativeAltitudeAvailable() {
status = CMAltimeter.authorizationStatus()
self.altimeter.startRelativeAltitudeUpdates(to: OperationQueue.main) { (data, _error) in
DispatchQueue.main.async {
error = _error != nil ? _error!.localizedDescription : "<nil>"
print(error)
pressure = data != nil ? String(format: "%f", data!.pressure.doubleValue) : ""
}
}
}
PS: the documentation of Core Motion (which CMAltimeter is part of) says that the NSMotionUsageDescription .info.plist property needs to be defined for all Core Motion service. I have that property in place, but it does not seem to make a difference.
Note that the following is a work-around. I urge everybody to file a bug-report with Apple, to make sure there is pressure on Apple to fix this.
First of all, the
NSMotionUsageDescriptionkey must be defined in the app's.info.plistfile.Others have suggested the
CMSensorRecorderwork-around. It turns out that the "Fitness Tracking" setting in the Settings App needs to be enabled for that to work.When the
authorizationStatusis.restricted,then the user first needs to switch on Settings > "Privacy & Security" > "Motion & Fitness" > "Fitness Tracking"When the
authorizationStatusis.notDetermined,then start theCMSensorRecorder. A "Motion & Fitness" privacy settings will be added to your app's settings, and the user will be asked to authorise by iOS. When the user accepts,authorizationStatuschanges to.authorizedand you can start theCMAltimeter.When the
authorizationStatusis.denied,the user needs to switch on the "Motion & Fitness" privacy setting of your app.The following code worked for me: