snapp-mobile/zeplinpersistence
A Swift Package that wraps up a CoreData container for persisting user's notifications
Overview
ZeplinPersistence is the data layer for the Zeplin Mobile app. It handles storing notifications using CoreData and manages authentication tokens through the iOS keychain. The package uses app groups to share data between the main app and extensions like widgets or notification extensions.
The PersistenceController sets up a CoreData stack that can work with shared containers or in-memory stores for testing. The TokenRepository is an actor that safely manages OAuth tokens, handling refreshes and waiting for the device to unlock before accessing the keychain.
Documentation
For more information visit Documentation.
Installation
Add ZeplinPersistence to your project using Swift Package Manager. In Xcode, go to File → Add Package Dependencies and enter the repository URL, or add it to your Package.swift file.
dependencies: [
.package(url: "https://github.com/Snapp-Mobile/ZeplinPersistence.git", from: "0.1.0")
]Usage
Create a persistence controller for your app target. The controller handles setting up the CoreData stack with the appropriate app group identifier.
import ZeplinPersistence
let persistence = PersistenceController(target: .iOSApp, inMemory: false)
let context = persistence.container.viewContextFor testing, use the built-in test controller that creates an in-memory store.
let testPersistence = PersistenceController.testThe token repository manages authentication tokens across your app. Initialize it with your keychain settings and app target.
let tokenRepo = TokenRepository(
key: "auth-token",
serviceName: "com.snapp.zeplin",
appTarget: .iOSApp,
configuration: apiConfig
)License
ZeplinPersistence is available under the MIT license. See the LICENSE file for details.
Package Metadata
Repository: snapp-mobile/zeplinpersistence
Default branch: main
README: README.md