Latest 2.0.1
Homepage https://github.com/tribalworldwidelondon/CassowarySwift
License MIT
Platforms ios 8.0

Cassowary Swift

Build Status

A Swift port of the Cassowary linear constraints solver. Tested on OS X, iOS and Linux.

Example usage

let solver = Solver()

let left =  Variable("left")
let mid =   Variable("mid")
let right = Variable("right")

try solver.addConstraint(mid == (left + right) / 2)
try solver.addConstraint(right == left + 10)
try solver.addConstraint(right <= 100)
try solver.addConstraint(left >= 0)

solver.updateVariables()

// left.value is now 90.0
// mid.value is now 95.0
// right.value is now 100.0

try solver.addEditVariable(variable: mid, strength: Strength.STRONG)
try solver.suggestValue(variable: mid, value: 2)

solver.updateVariables()

// left.value is now 0.0
// mid.value is now 5.0
// right.value is now 10.0

Documentation

Documentation can be found on CocoaDocs

Acknowledgements

Cassowary Swift originally started as a direct port of kiwi-java by Alex Birkett

Latest podspec

{
    "name": "Cassowary",
    "version": "2.0.1",
    "summary": "A Swift port of the Cassowary linear constraint solver",
    "description": "A library that implements the Cassowary linear constraint solving algorithm in pure Swift",
    "homepage": "https://github.com/tribalworldwidelondon/CassowarySwift",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": "Tribal Worldwide London",
    "source": {
        "git": "https://github.com/tribalworldwidelondon/CassowarySwift.git",
        "tag": "2.0.1"
    },
    "source_files": "Sources/**/*.{swift}",
    "platforms": {
        "ios": "8.0"
    },
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "4.1"
    },
    "testspecs": [
        {
            "name": "Tests",
            "test_type": "unit",
            "source_files": "Tests/CassowaryTests/*.{swift}"
        }
    ]
}

Pin It on Pinterest

Share This