Skip to content

SwiftyLab/swift-contexts

Repository files navigation

swift-contexts

API Docs Swift Package Manager Compatible Swift Platforms CI/CD CodeFactor codecov

A no-boilerplate dependency management library for Swift.

Overview

When following Single responsibility in SOLID principle, code is divided into multiple types/functions each representing a responsibility/goal, i.e. storage access, database and networking, scheduling etc.

These types/functions can depend on each other and it is important these dependences need to be controlled to deterministically test each responsibility, free from side effects from external components, i.e. file systems, network connectivity and speed, server uptime etc.

This library addresses this concern by allowing controlling dependencies with following features:

  • Propagating dependencies throughout application in a way that is more ergonomic than explicitly passing them around everywhere, but safer than having a global dependency.
  • Override dependencies in different parts of application for testing or customizing experiences in various parts.

Requirements

Platform Minimum Swift Version Installation Status
iOS 8.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+ 5.2 Swift Package Manager Fully Tested
Linux 5.2 Swift Package Manager Fully Tested
Windows 5.2 Swift Package Manager Fully Tested

Installation

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding swift-contexts as a dependency is as easy as adding it to the dependencies value of your Package.swift.

.package(url: "https://github.com/SwiftyLab/swift-contexts.git", from: "1.0.0"),

Then you can add the Contexts module product as dependency to the targets of your choosing, by adding it to the dependencies value of your targets.

.product(name: "Contexts", package: "swift-contexts"),

Usage

See the full documentation for API details and use cases.

Contributing

If you wish to contribute a change, suggest any improvements, please review our contribution guide, check for open issues, if it is already being worked upon or open a pull request.

License

swift-contexts is released under the MIT license. See LICENSE for details.