Latest 1.0.1
Homepage https://github.com/johnsundell/require
License MIT
Platforms ios 8.0, osx 10.9, watchos 2.0, tvos 9.0
Frameworks Foundation
Authors

✅ Require

CocoaPods
Carthage
Swift PM
Twitter

Require lets you easily require Optional values to be non-nil, or crash gracefully.

Sometimes you have optional values in your code that are not really optional, and will cause your
application to enter an undefined state if nil. Require makes it easy to avoid such states, by
causing a crash with rich debug information, to enable you to much easier hunt down & fix the bug.

Usage

Call require() on any Optional, optionally giving a hint for debugging purposes:

class ConfigurationLoader {
    func load() -> Configuration {
        let data = readJSONFile().require(hint: "Verify that Config.JSON is valid")
        let config: Configuration? = try? unbox(data: data)
        return config.require()
    }
}

Installation

Swift Package Manager:

Add .Package(url: "[email protected]:johnsundell/require.git", majorVersion: 1) to your Package.swift file.

CocoaPods:

Add pod "Require" to your Podfile.

Carthage:

Add github "johnsundell/require" to your Cartfile.

Manual:

Clone the repo and drag the file Require.swift into your Xcode project.

Help, feedback or suggestions?

  • Open an issue if you need help, if you found a bug, or if you want to discuss a feature request.
  • Open a PR if you want to make some change to Require.
  • Contact @johnsundell on Twitter for discussions, news & announcements about Require.

Latest podspec

{
    "name": "Require",
    "version": "1.0.1",
    "summary": "Require optional values to be non-nil, or crash gracefully",
    "description": "Easily require optional values to be non-nil, or crash gracefully",
    "homepage": "https://github.com/johnsundell/require",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "John Sundell": "[email protected]"
    },
    "social_media_url": "https://twitter.com/johnsundell",
    "platforms": {
        "ios": "8.0",
        "osx": "10.9",
        "watchos": "2.0",
        "tvos": "9.0"
    },
    "source": {
        "git": "https://github.com/johnsundell/require.git",
        "tag": "1.0.1"
    },
    "source_files": "Sources/**/*",
    "frameworks": "Foundation",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This