0.9.1
What's Changed
0.9.1 is a focused patch release for the MainActor Observation rollout. It adds the Observation-aware generated @NSModelActor initializer and fixes the retained-domain teardown issue found during QA.
Highlights
-
@NSModelActornow generatesinit(observationDomain:)when initializer generation is enabled. -
The generated initializer derives the container from
CDEObservationDomain.modelContainer, creates a background context, registers it as an Observation producer, and retains the domain/registration for the actor's lifetime. -
Generated actors also receive a no-argument
saveObservedChanges().- Actors created with
init(observationDomain:)use the retained registered-context save path. - Actors created with
init(container:)fall back tomodelContext.save()and emit a one-time warning that no CDE Observation metadata will be produced.
- Actors created with
-
Inline construction is supported:
let writer = ItemWriter(observationDomain: CDEObservationDomain(container: container))
Fixes
- Fixed off-main teardown of a retained
CDEObservationDomainby usingisolated deinit. - Generated observed actors now invalidate their retained producer registration in
deinit, and the domain removes invalidated registrations from its retained list. - Simplified the generated
saveObservedChanges()path to remove the dead branch reported by QA.
Compatibility Notes
- MainActor Observation is now gated with
#if compiler(>=6.2). - The package tools-version and non-Observation features remain Swift 6.0-compatible.
- Observation-specific APIs require a Swift 6.2+ compiler and the existing iOS 17 / macOS 14 platform families.
NSModelActor.saveObservedChanges(in:)remains available for custom or plain actor contexts that do not retain a producer registration.
Documentation
- Updated
Docs/NSModelActorGuide.md,Docs/ObservationGuide.md, and the DocC overview for the generated initializer, inline domain lifetime, fallback warning, custom initializer cleanup, and Swift compiler 6.2+ Observation requirement.
Validation
bash Scripts/run-tests.shpassed with 340 tests / 44 suites.bash Scripts/test-generated-flow.shpassed, including external generated fixture build and run.git diff --checkpassed.