What problem does it solve?
CoreMotion helps you reliably access and interpret iOS/watchOS device motion and activity signals without manually stitching together raw accelerometer/gyro/compass data.
Core Features & Use Cases
- Read fused motion & orientation: Use
CMMotionManager to get CMDeviceMotion attitude (pitch/roll/yaw), user acceleration, heading, and rotation rate for responsive motion-based interactions.
- Count steps & estimate movement: Use
CMPedometer for step counts, distance, pace, cadence, and floor ascents in fitness and navigation contexts.
- Detect user activity mode: Use
CMMotionActivityManager to classify walking/running/stationary/automotive/cycling with confidence handling.
- Track altitude: Use
CMAltimeter for relative altitude (pressure-based) and absolute altitude (when available).
- Practical production guidance: Covers Info.plist permissions, availability checks, choosing attitude reference frames, update interval tradeoffs, and common battery/performance pitfalls.
Quick Start
Start by adding NSMotionUsageDescription to your app’s Info.plist, then create a single CMMotionManager instance and begin the appropriate start*Updates call after checking sensor availability.