Apple's framework for accessing motion and environmental sensor data. Core Motion provides access to accelerometer, gyroscope, magnetometer, and barometer data for motion tracking.
of iOS users worldwide can use Core Motion (iOS 4+ required)
| iOS Version | Market Share | Status |
|---|---|---|
| iOS 18.7 | 30.3% | Supported |
| iOS 18.6 | 29.8% | Supported |
| iOS 26.1 | 10.7% | Supported |
| iOS 18.5 | 6.0% | Supported |
| iOS 16.7 | 2.3% | Supported |
| iOS 26.2 | 2.0% | Supported |
| iOS 18.3 | 1.8% | Supported |
| iOS 15.8 | 1.8% | Supported |
| iOS 11.0 | 1.7% | Supported |
| iOS 17.6 | 1.7% | Supported |
Accelerometer data
Gyroscope data
Device motion and attitude
Step counting and activity detection
Barometric pressure (altimeter)
Motion gesture recognition
Monitor device motion using accelerometer and gyroscope
import CoreMotion
class MotionManager {
let motionManager = CMMotionManager()
func startTracking() {
if motionManager.isDeviceMotionAvailable {
motionManager.deviceMotionUpdateInterval = 0.1
motionManager.startDeviceMotionUpdates(to: .main) { motion, error in
guard let motion = motion else { return }
let attitude = motion.attitude
print("Roll: \(attitude.roll)")
print("Pitch: \(attitude.pitch)")
print("Yaw: \(attitude.yaw)")
}
}
}
func stopTracking() {
motionManager.stopDeviceMotionUpdates()
}
}Apple's framework for accessing motion and environmental sensor data. Core Motion provides access to accelerometer, gyroscope, magnetometer, and barometer data for motion tracking.
Core Motion is available on iOS 4 and later. Currently, 99.8% of iOS users worldwide can use this framework.
Related frameworks include Healthkit. Each has different capabilities and iOS version requirements.