Latest 0.1
License MIT
Platforms ios 10.0
Frameworks Foundation

The best way to deal with Measurements and Units in Swift.

Measurements and Units are newly introduced in iOS 10.


  • before

Measurement(value: 3, unit: .kilometers) + Measurement(value: 4, unit: .kilometers)

- after

3.kilometers + 4.kilometers

SwiftMeasurement supports all units declared in Foundation framework.

  • UnitLength
  • UnitFuelEfficiency
  • UnitElectricResistance
  • UnitIlluminance
  • UnitDispersion
  • UnitElectricCharge
  • UnitVolume
  • UnitEnergy
  • UnitAngle
  • UnitDuration
  • UnitTemperature
  • UnitFrequency
  • UnitPower
  • UnitElectricCurrent
  • UnitElectricPotentialDifference
  • UnitAcceleration
  • UnitSpeed
  • UnitArea
  • UnitMass
  • UnitConcentrationMass
  • UnitPressure


Current version is compatible with:

  • Swift 3.0+
  • iOS 10 or later


SwiftMeasurement supports multiple methods for installing the library in a project.

Installation with CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like SwiftMeasurement in your projects. You can install it with the following command:

$ gem install cocoapods


To integrate SwiftMeasurement into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'SwiftMeasurement'

Then, run the following command:

$ pod install

Installation with Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate SwiftMeasurement into your Xcode project using Carthage, specify it in your Cartfile:

github "ken0nek/SwiftMeasurement"

Run carthage to build the framework and drag the built SwiftMeasurement.framework into your Xcode project.

Future features

  • [ ] Describe relations between dimentions. [L, M, T, L/T, L/T^2, etc…]

// Speed * Duration -> Length

func * (lhs: Measurement<UnitSpeed>, rhs: Measurement<UnitDuration>) -> Measurement<UnitLength> {
    let v = lhs.converted(to: .baseUnit()).value * rhs.converted(to: .baseUnit()).value
        return Measurement<UnitLength>(value: v, unit: .baseUnit())


let duration = 10.hours // 10.0 hr
let speed = 5.kilometersPerHour // 5.0 km/h

(speed * duration).converted(to: .kilometers) // 50.00004 km

Latest podspec

    "name": "SwiftMeasurement",
    "version": "0.1",
    "summary": "The best way to deal with Measurements and Units in Swift",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Ken Tominaga": "[email protected]"
    "platforms": {
        "ios": "10.0"
    "source": {
        "git": "",
        "tag": "0.1"
    "source_files": "Sources/**/*",
    "frameworks": "Foundation",
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This