Read device sensor data -- accelerometer, gyroscope, magnetometer, pedometer, and activity recognition -- on iOS and watchOS. CoreMotion fuses raw sensor inputs into processed device-motion data and provides pedometer/activity APIs for fitness and navigation use cases. Targets Swift 6.2 / iOS 26+.
Add NSMotionUsageDescription to Info.plist with a user-facing string explaining why your app needs motion data. Without this key, the app crashes on first access.
CoreMotion uses CMAuthorizationStatus for pedometer and activity APIs. Sensor APIs (accelerometer, gyro) do not require explicit authorization but do require the usage description key.
Получите доступ к акселерометру, гироскопу, магнитометру, шагомеру и данным распознавания активности с помощью CoreMotion. Используйте при чтении данных датчиков устройства, подсчете шагов, обнаружении активности пользователя (ходьба/бег/вождение автомобиля), отслеживании изменений высоты или реализации взаимодействия на основе движения в приложениях iOS/watchOS. Источник: dpearson2699/swift-ios-skills.