A modular, testable collection of lightweight wrappers for common Foundation types, designed for seamless use with swift-dependencies. This package makes it easy to mock, inject, and override behaviours like UserDefaults, Bundle, and file system operations in both production and test environments.
Add this package via Swift Package Manager:
.product(name: "FoundationDependencies", package: "foundation-dependencies")Comprehensive documentation is available via Swift Package Index:
➡️ Browse Documentation on Swift Package Index
| Client | Description |
|---|---|
mainBundleClient |
A wrapper around Bundle, exposing APIs for loading resources via a BundleResourceProvider abstraction. |
userDefaultsClient |
A testable interface for UserDefaults, built using UserDefaultsStoreProtocol. Ideal for dependency injection and isolating persistent state in tests. |
fileSystemClient |
A robust file system interface supporting operations such as reading, writing, copying, moving, and deleting files or directories. Suitable for sandboxed storage and fully mockable for tests. |
fileSystemResourceClient |
A factory for creating typed file stores that conform to FileSystemOperations. Supports saving and loading Codable values and binary data into specific folders and subfolders, without exposing raw file system APIs. |
loggerClient |
An interface to os.Logger, auto-populated with the MainBundle bundle identifier (even if you're logging outside the main bundle). |
Note
Many additional dependencies likedate,uuid, andcalendarare provided transitively viaswift-dependencies.
See the complete list of built-ins.