Latest 0.7.0
License MIT
Platforms ios 8.0
Dependencies RxSwift
Frameworks Foundation, CoreMotion


CocoaPods Compatible
Carthage compatible

RxMotionKit is a motion sensors managing library written in Swift.


  • [x] CoreMotion RxSwift support
  • [x] Swifty interface
  • [x] Pleasant data model


Library wraps CoreMotion and RxSwift frameworks and provides pleasant way to obtain data from sensors.


  • Xcode 8.1+
  • Swift 3.0+



RxMotionKit is available through CocoaPods. To install
it, simply specify it in your Podfile:

pod 'RxMotionKit', '~> 0.7.0'

Then, run the following command:

$ pod install


Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate RxMotionKit into your Xcode project using Carthage, specify it in your Cartfile:

github "rsobolewski/RxMotionKit" ~> 0.7.0

Run carthage update to build the frameworks and drag them into your Xcode project.


Start motions source updates

To start updating data from sensors import RxMotionKit module and get reference to singleton instance of MotionManager:

import RxSwift
import RxMotionKit

unowned let motionManager = MotionManager.shared

subscribe an Observable:

    .subscribe(onNext: { (data) in
        // Handle received data

and start updating selected sources:

    withInterval: 5.0

For convenient usage when you want to obtain few updates you can use take to automatically stop updates when defined limit is reached:

    .subscribe(onNext: { (data) in
        // Handle received data

Stop motions source updates

To stop updates from selected sources:


Types of motion source

All motion sources that are available:

  • accelerometr – Accelerometer
  • gyroscope – Gyroscope
  • magnetometr – Magnetometr
  • deviceMotion – DeviceMotion

Also you can conveniently specify all motion sources using MotionSourceType.all.

Types of Observables

There are several types of Observables provided by MotionManager:

  • rx_didUpdateMotionData – general observable for motion data updates, that merges all events from all source updates
  • rx_didUpdateAccelerometerData – accelerometer updates
  • rx_didUpdateGyroscopeData – gyroscope updates
  • rx_didUpdateMagnetometerData – magnetometer updates
  • rx_didUpdateDeviceMotionData – device motion updates

Updates configuration

All sources require the update time interval, that must be provided in method which start updates:

let updateTimeInterval = 1.0 // 1 sec
startUpdating([.accelerometer], withInterval: updateTimeInterval)

For device motion updates you can choose a reference frame for attitude, which will be default if you not provide any.

startUpdating([.accelerometer], withInterval: updateTimeInterval, referenceFrame: .xArbitraryZVertical)


If you want to contribute, please submit a pull request. For code consistency please use SwiftLint with configuration from this repository.


Robert Sobolewski, contact me on Twitter


RxMotionKit is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "RxMotionKit",
    "version": "0.7.0",
    "summary": "RxMotionKit - reactive motion sensors managing library ud83cudfc3",
    "description": "RxMotionKit is a reactive motion sensors managing library for CoreMotion iOS framework written using RxSwift ud83cudfc3",
    "authors": {
        "Robert Sobolewski": "[email protected]"
    "social_media_url": "",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "source": {
        "git": "",
        "tag": "0.7.0"
    "platforms": {
        "ios": "8.0"
    "source_files": "Sources/RxMotionKit/*.swift",
    "frameworks": [
    "dependencies": {
        "RxSwift": [
            "~> 3.0"
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This