Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/GoodRequest/GoodPersistence
💾 GoodPersistence is an iOS library that simplifies caching data in keychain and UserDefaults. Using a property wrapper, it reduces the complexity of implementing caching mechanisms, making it easier for developers to focus on app functionality. Compatible with latest Swift and supports all iOS devices. Easy to install with SPM.
https://github.com/GoodRequest/GoodPersistence
ios keychain library persistence swift userdefaults
Last synced: 6 days ago
JSON representation
💾 GoodPersistence is an iOS library that simplifies caching data in keychain and UserDefaults. Using a property wrapper, it reduces the complexity of implementing caching mechanisms, making it easier for developers to focus on app functionality. Compatible with latest Swift and supports all iOS devices. Easy to install with SPM.
- Host: GitHub
- URL: https://github.com/GoodRequest/GoodPersistence
- Owner: GoodRequest
- License: mit
- Created: 2023-01-25T11:04:36.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-16T09:46:58.000Z (23 days ago)
- Last Synced: 2024-10-17T20:43:54.130Z (22 days ago)
- Topics: ios, keychain, library, persistence, swift, userdefaults
- Language: Swift
- Homepage:
- Size: 403 KB
- Stars: 35
- Watchers: 3
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
- fucking-awesome-swift - GoodPersistence - 💾 GoodPersistence simplifies caching data in keychain and UserDefaults. Using a property wrappers. (Libs / Security)
- awesome-swift - GoodPersistence - 💾 GoodPersistence simplifies caching data in keychain and UserDefaults. Using a property wrappers. (Libs / Security)
README
![Logo](good-persistence.png)
# GoodPersistence
[![iOS Version](https://img.shields.io/badge/iOS_Version->=_12.0-brightgreen?logo=apple&logoColor=green)]()
[![Swift Version](https://img.shields.io/badge/Swift_Version-5.5-green?logo=swift)](https://docs.swift.org/swift-book/)
[![Supported devices](https://img.shields.io/badge/Supported_Devices-iPhone/iPad-green)]()
[![Contains Test](https://img.shields.io/badge/Tests-YES-blue)]()
[![Dependency Manager](https://img.shields.io/badge/Dependency_Manager-SPM-red)](#swiftpackagemanager)A property wrapper, designed to simplify the process of caching data into the keychain and UserDefaults storage.
This wrapper makes it possible to quickly and easily implement caching mechanisms in the applications,
without having to write extensive amounts of code.
The property wrapper takes care of all the underlying complexity, allowing developers to focus on their application's functionality.## Documentation
You can check GoodPersistence package documentation [here](https://goodrequest.github.io/GoodPersistence/documentation/goodpersistence/)## Installation
### Swift Package ManagerCreate a `Package.swift` file and add the package dependency into the dependencies list.
Or to integrate without package.swift add it through the Xcode add package interface.[//]: # (Don't forget to add the version once available)
```swiftimport PackageDescription
let package = Package(
name: "SampleProject",
dependencies: [
.Package(url: "https://github.com/GoodRequest/GoodPersistence" from: "addVersion")
]
)```
## Usage
Storing to the UserDefaults
```swift
@UserDefaultValue(String(describing: AppState.self), defaultValue: .initial)
var appState: AppState
```Storing to the KeyChain
```swift
@KeychainValue("accessToken", defaultValue: "", accessibility: .afterFirstUnlockThisDeviceOnly)
var accessToken: String
```Using Publishers
```swift
lazy var appStatePublisher = _appState.publisher
.dropFirst()
.removeDuplicates()
.eraseToAnyPublisher()
```## License
GoodPersistence is released under the MIT license. See [LICENSE](LICENSE.md) for details.