CocoaPods trunk is moving to be read-only. Read more on the blog, there are 14 months to go.
| TestsTested | ✗ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Oct 2017 |
| SwiftSwift Version | 4.0 |
| SPMSupports SPM | ✓ |
Maintained by John Sundell.
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.
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()
}
}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.