Swiftpack.co - StanfordSpezi/SpeziStorage as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by StanfordSpezi.
StanfordSpezi/SpeziStorage 1.0.0
Spezi module to store information and credentials encrypted at rest
⭐️ 4
🕓 6 weeks ago
.package(url: "https://github.com/StanfordSpezi/SpeziStorage.git", from: "1.0.0")

Spezi Storage

Build and Test codecov DOI

The Spezi Storage framework provides two Modules that enable on-disk storage of information. The LocalStorage module can be used to store information that does not need to be encrypted. Credentials, keys, and other sensitive information that needs to be encrypted may be stored by using the SecureStorage module.


You need to add the Spezi Storage Swift package to your app in Xcode or Swift package.

[!IMPORTANT] If your application is not yet configured to use Spezi, follow the Spezi setup article to set up the core Spezi infrastructure.

You can configure the LocalStorage or SecureStorage module in the SpeziAppDelegate.

import Spezi
import SpeziLocalStorage
import SpeziSecureStorage

class ExampleDelegate: SpeziAppDelegate {
    override var configuration: Configuration {
        Configuration {
            // ...

You can then use the LocalStorage or SecureStorage class in any SwiftUI view.

struct ExampleStorageView: View {
    @Environment(LocalStorage.self) var secureStorage
    @Environment(SecureStorage.self) var secureStorage
    var body: some View {
        // ...

Alternatively, it is common to use the LocalStorage or SecureStorage module in other modules as a dependency: Spezi Module dependencies.

Local Storage

The LocalStorage module enables the on-disk storage of data in mobile applications.

The LocalStorage module defaults to storing data encrypted supported by the SecureStorage module. The LocalStorageSetting enables configuring how data in the LocalStorage module can be stored and retrieved.

Secure Storage

The SecureStorage module allows for the encrypted storage of small chunks of sensitive user data, such as usernames and passwords for internet services, using Apple's Keychain documentation.

Credentials can be stored in the Secure Enclave (if available) or the Keychain. Credentials stored in the Keychain can be made synchronizable between different instances of user devices.

Handling Credentials

Use the SecureStorage module to store a set of Credentials instances in the Keychain associated with a server that is synchronizable between different devices.

Handling Keys

Similar to Credentials instances, you can also use the SecureStorage module to interact with keys.

For more information, please refer to the API documentation.

The Spezi Template Application

The Spezi Template Application provides a great starting point and example using the Spezi Storage module.


Contributions to this project are welcome. Please make sure to read the contribution guidelines and the contributor covenant code of conduct first.


This project is licensed under the MIT License. See Licenses for more information.

Spezi Footer Spezi Footer


Stars: 4
Last commit: 6 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

6 weeks ago

What's Changed

Full Changelog: https://github.com/StanfordSpezi/SpeziStorage/compare/0.5.0...1.0.0

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics