Skip to content

Add SwiftData integration (ModelContainer dependency + ModelState)#2

Closed
corvid-agent wants to merge 1 commit into
mainfrom
swiftdata-modelstate
Closed

Add SwiftData integration (ModelContainer dependency + ModelState)#2
corvid-agent wants to merge 1 commit into
mainfrom
swiftdata-modelstate

Conversation

@corvid-agent

@corvid-agent corvid-agent commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Closing as redundant: main already contains the SwiftData ModelState feature (via the v3 PR #1 merge), so this slim, standalone branch is no longer needed for the fork. The swiftdata-modelstate branch is kept in case a SwiftData-only contribution to upstream is wanted later.

Introduce an additive, fully gated SwiftData integration that follows AppState's
existing conventions and does not change the package's platform requirements.

- ModelContainer as an AppState dependency, with `Application.modelContext(_:)`
  to access the shared main-actor `ModelContext` from non-view code, and a
  `modelContainer(_:)` registration convenience.
- `Application.ModelState<Model>`: a read-only `models` collection (live fetch
  via a `FetchDescriptor`) plus `insert`/`delete`/`save`/`deleteAll`.
- `@ModelState` property wrapper exposing `[Model]`; mutate via the projected
  value (`$items.insert/delete/save/deleteAll`).
- Unit tests (in-memory container) and a runnable example package.
- Documentation: usage-modelstate guide plus README and usage-overview updates.

Everything is gated behind `#if canImport(SwiftData)` and `@available`
(iOS 17 / macOS 14 / tvOS 17 / watchOS 10 / visionOS 1), so the base
iOS 15 / macOS 11 deployment targets and non-Apple platforms are unaffected.

https://claude.ai/code/session_01KQ6g1YCLbH3wZkP8SuJ9vz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants