-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Husnain Ali edited this page Sep 27, 2026
·
5 revisions
SwiftLocalStorage saves the Codable structs your app already has, using SwiftData under the hood.
You don't write @Model classes or mapping code, and SwiftData never leaks into your domain layer.
The structs your API returns are the same ones you store.
It has no dependencies, is built for Swift 6 strict concurrency, and runs on iOS 17, macOS 14, tvOS 17, watchOS 10 and visionOS 1 or later.
dependencies: [
.package(url: "https://github.com/ihusnainalii/SwiftLocalStorage.git", from: "1.1.1"),
]In Xcode: File ▸ Add Package Dependencies…, paste the repository URL and choose Up to Next Major Version.
import SwiftLocalStorage
struct User: Codable, Identifiable, Sendable {
let id: Int
var name: String
var role: String
}
let storage = try LocalStorage()
try await storage.save(User(id: 1, name: "Ada", role: "admin"), expiration: .hours(1))
let ada = try await storage.fetch(User.self, id: 1)
let users = try await storage.fetch(User.self, options: FetchOptions(sort: .newestFirst, limit: 20))
for try await users in storage.updates(of: User.self) { // live query for SwiftUI
print(users.count)
}| Feature | Page |
|---|---|
| What happens when you save, read, or watch data | How It Works |
| Entity CRUD, key-value entries, cache expiration, metadata, repositories | Getting Started |
| Sorting, paging, closure filters, batched iteration | Querying |
Up to three indexed fields per type, in-store filters (equals, ranges, hasPrefix, oneOf), ordering, counts, pages, live indexed queries |
Indexed Fields |
| Typed change feeds and coalescing live queries | Observing Changes |
| Versioned DTOs with typed or raw-JSON migration steps | Migrating Stored DTOs |
| In-memory stores and clock injection for tests and previews | Testing |
| What 1.x promises | API Stability |
| Timings on real hardware | Benchmarks |
| Moving between versions | Upgrading |
| Questions and known limitations | FAQ |
- The README has the full guide and a complete worked example.
- Releases and CHANGELOG.
- Every release comes with a static DocC archive you can host yourself.
- Want to help? Read Contributing. Found a security problem? See the security policy. Questions go to Discussions.
SwiftLocalStorage, licensed under Apache 2.0. These pages cover v1.1.1.