SwiftStash v0.2.0 lets you choose and inject the store, declare a key's default once, and persist properties of @Observable models.
There are no breaking changes to the public API and no persisted-data migration: values written by 0.1.0 read as before.
Highlights
StashKey<Value>: a key that carries its type and default.@Stash(.launchCount) var launchCount: Intin a model and@Stashed(.launchCount)in a view read the same default.StashContainer: a class states its store once (let stashStore: StashStore), and every@Stashproperty follows it, so tests inject a suite without passing it to each property.StashObservable(iOS 17 / macOS 14):@ObservationIgnored @Stash(…)properties of an@Observableclass take part in observation. There is no mirror and no restore at launch, and writes from elsewhere update the model's observers..stashStore(_:): a hosted@Stashedtakes its store from the SwiftUI environment, the counterpart of.defaultAppStorage(_:).- Store configuration: an instance-based
SwiftStash.configureUserDefaults(_:), package-levelStashScopes, and APIs to read and reset the configuration, all on one documented resolution chain.
Changes and fixes
- Operation logs go to the unified log's
.debuglevel, so reads and writes no longer fill the stored log. Errors stay at.error. @Stashedreads back the stored value right after a write.
See CHANGELOG.md for the full list.