
Core Motion
Wraps Apple's CoreMotion framework for reading iPhone and Apple Watch sensors: accelerometer, gyroscope, magnetometer, pedometer, and activity recognition. You get code patterns for both real-time updates and historical queries, plus the usual gotchas like needing exactly one CMMotionManager instance and remembering to add NSMotionUsageDescription to your plist. Covers the polling pattern for games, device motion fusion for attitude tracking, and the pedometer APIs for step counting and floor detection. The battery impact table is helpful since sensor update rates directly trade responsiveness for power. Solid reference if you're building fitness tracking, motion-based UI, or anything that needs to know whether the user is walking, driving, or sitting still.
- skills.sh installs
- 3.8K
- GitHub stars
- 1.3K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add dpearson2699/swift-ios-skills --skill core-motion --agent claude-codeInstalls into .claude/skills of the current project.
Files
CoreMotion
Read device motion, pedometer/activity, altitude, headphone, batched-workout, and submersion sensors with Core Motion. Scope: Swift 6.3, iOS 26+.
Contents
- Setup
- CMMotionManager: Sensor Data
- Processed Device Motion
- CMPedometer: Step and Distance Data
- CMMotionActivityManager: Activity Recognition
- CMAltimeter: Altitude Data
- Update Intervals and Battery
- Common Mistakes
- Review Checklist
- References
Setup
Info.plist
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.
<key>NSMotionUsageDescription</key>
<string>This app uses motion data to track your activity.</string>
Authorization
Sponsors
Details
- Repository
- github.com/dpearson2699/swift-ios-skills
- Categories
- Mobile Development, Design & UI/UX
- First seen
- Apr 16, 2026
More from dpearson2699/swift-ios-skills
All 98- Natural Language3.8K
- Speech Recognition3.8K
- Device Integrity3.8K
- Contacts Framework3.8K
- Alarmkit3.8K
- Core Nfc3.8K
- Swift Codable3.8K
- Tipkit3.8K
- App Clips3.8K
- Permissionkit3.7K
- Energykit3.7K
- Shareplay Activities3.7K
- Weatherkit3.6K
- Activitykit3.5K
- Cloudkit3.5K
- Photokit3.4K
- Mapkit3.4K
- Swiftui Webkit3.4K
- Realitykit3.4K
- Avkit3.4K
- Spritekit3.3K
- Cryptokit3.3K
- Metrickit3.3K
- Pdfkit3.3K