# \#swiftdata

**URL:** https://forums.swift.org/tag/swiftdata/854.md

[Latest](https://forums.swift.org/latest.md) · [Categories](https://forums.swift.org/categories.md) · [Tags](https://forums.swift.org/tags.md)

---

## [Amethyst Vein - A cross-platform, open source, SwiftData alternative](https://forums.swift.org/t/amethyst-vein-a-cross-platform-open-source-swiftdata-alternative/89009)

<div class="topic-metadata">

**Author:** [@MiaKoring](https://forums.swift.org/u/MiaKoring)\
**Replies:** 11\
**Last updated:** [October 17, 2026, 2:39pm UTC](https://forums.swift.org/t/amethyst-vein-a-cross-platform-open-source-swiftdata-alternative/89009 "2026-10-17T14:39:39Z")

</div>

TLDR: Amethyst Vein is a SwiftData inspired database framework, with UI support for SwiftUI and SwiftCrossUI out of the box, with a UI independent surface available too. It's compatible with Apple, Linux, Android and Win…

---

## [SwiftData + Transferable](https://forums.swift.org/t/swiftdata-transferable/82299)

<div class="topic-metadata">

**Author:** [@bdkjones](https://forums.swift.org/u/bdkjones)\
**Replies:** 1\
**Last updated:** [October 3, 2026, 9:19pm UTC](https://forums.swift.org/t/swiftdata-transferable/82299 "2026-10-03T21:19:26Z")

</div>

Suppose we have a SwiftData Model: @Model class Contact { var firstName: String? var lastName: String? } We make this model Codable (I’ll skip showing the implementation; it’s standard). Now we want to allow o…

---

## [\#Predicate a bit tricky](https://forums.swift.org/t/predicate-a-bit-tricky/88996)

<div class="topic-metadata">

**Author:** [@somu](https://forums.swift.org/u/somu)\
**Replies:** 0\
**Last updated:** [August 16, 2026, 8:05am UTC](https://forums.swift.org/t/predicate-a-bit-tricky/88996 "2026-08-16T08:05:52Z")

</div>

Hi, Overview I am finding #Predicate to be a bit tricky when used with Swift Data It compiles fine but crashes at runtime I know the fix for the problem just wondering if such pitfalls can be avoided at compile time E…

---

## [DayType — A Swift API for dates without the time baggage](https://forums.swift.org/t/daytype-a-swift-api-for-dates-without-the-time-baggage/85747)

<div class="topic-metadata">

**Author:** [@Drekka](https://forums.swift.org/u/Drekka)\
**Replies:** 12\
**Last updated:** [April 3, 2026, 8:29am UTC](https://forums.swift.org/t/daytype-a-swift-api-for-dates-without-the-time-baggage/85747 "2026-04-03T08:29:31Z")

</div>

Hello everyone, I'd like to share a package I've been working on called DayType. The problem DayType solves Swift's Date APIs are great, but they are also limited by their focus on representing points in time. This me…

---

## [DataStoreKit: A SwiftData custom data store implementation](https://forums.swift.org/t/datastorekit-a-swiftdata-custom-data-store-implementation/85317)

<div class="topic-metadata">

**Author:** [@asymbas](https://forums.swift.org/u/asymbas)\
**Replies:** 0\
**Last updated:** [March 13, 2026, 12:30am UTC](https://forums.swift.org/t/datastorekit-a-swiftdata-custom-data-store-implementation/85317 "2026-03-13T00:30:50Z")

</div>

Hello! I am announcing a preview of my library called DataStoreKit. The package is built around SwiftData and its custom data store APIs. DatabaseStore and DatabaseConfiguration is the first implemented pair that uses S…

---

## [SwiftData Models and Sort Descriptors Only Work in Release In One Swift File](https://forums.swift.org/t/swiftdata-models-and-sort-descriptors-only-work-in-release-in-one-swift-file/85244)

<div class="topic-metadata">

**Author:** [@nneuh07](https://forums.swift.org/u/nneuh07)\
**Replies:** 1\
**Last updated:** [March 11, 2026, 7:58am UTC](https://forums.swift.org/t/swiftdata-models-and-sort-descriptors-only-work-in-release-in-one-swift-file/85244 "2026-03-11T07:58:27Z")

</div>

Hey everyone, I found a possible SwiftData or Swift compiler bug, that only is visible on Release builds with nested sort descriptors on an optional relationship. In a minimal repro, sorting a @Query by a nested option…

---

## [Handling large SwiftData import](https://forums.swift.org/t/handling-large-swiftdata-import/83455)

<div class="topic-metadata">

**Author:** [@danielhaven](https://forums.swift.org/u/danielhaven)\
**Replies:** 11\
**Last updated:** [December 3, 2025, 8:07am UTC](https://forums.swift.org/t/handling-large-swiftdata-import/83455 "2025-12-03T08:07:35Z")

</div>

I have a Swift iOS app that handles a background task that involves importing a large number of records. Currently in the 5,000s. I am using a model actor to upsert (based on the record’s id) into my table. The time it t…

---

## [Question about SwiftData and Concurrency interoperability](https://forums.swift.org/t/question-about-swiftdata-and-concurrency-interoperability/83097)

<div class="topic-metadata">

**Author:** [@thedan84](https://forums.swift.org/u/thedan84)\
**Replies:** 14\
**Last updated:** [November 14, 2025, 7:38pm UTC](https://forums.swift.org/t/question-about-swiftdata-and-concurrency-interoperability/83097 "2025-11-14T19:38:26Z")

</div>

Hello all, I’m running into a weird problem. When downloading large amounts of data from an API (~7000 items), and then saving it to SwiftData, I get hangs in Profiler. I’ve already tried all kinds of things in regards …

---

## [Is that OK to created a modelContext inside an async func?](https://forums.swift.org/t/is-that-ok-to-created-a-modelcontext-inside-an-async-func/82772)

<div class="topic-metadata">

**Author:** [@SecondOpion](https://forums.swift.org/u/SecondOpion)\
**Replies:** 0\
**Last updated:** [October 21, 2025, 7:04am UTC](https://forums.swift.org/t/is-that-ok-to-created-a-modelcontext-inside-an-async-func/82772 "2025-10-21T07:04:20Z")

</div>

The modelContext is not Sendable, when I have an async func, such like download data from Internet, I can't pass the modelContext as parameter, the compiler complaints said it causes data race. So I shared the modelCon…

---

## [iOS Simulator: App data directory changes on every run (container path stable)](https://forums.swift.org/t/ios-simulator-app-data-directory-changes-on-every-run-container-path-stable/82011)

<div class="topic-metadata">

**Author:** [@solo](https://forums.swift.org/u/solo)\
**Replies:** 1\
**Last updated:** [September 8, 2025, 4:33pm UTC](https://forums.swift.org/t/ios-simulator-app-data-directory-changes-on-every-run-container-path-stable/82011 "2025-09-08T16:33:19Z")

</div>

Normally, I can grab my app’s SQLite database from the Simulator by navigating into the container, then into the app’s Documents directory, and opening it in DB Browser. Up until now, the container path itself has alway…

---

## [SwiftData context is empty after saving](https://forums.swift.org/t/swiftdata-context-is-empty-after-saving/75091)

<div class="topic-metadata">

**Author:** [@DanielC](https://forums.swift.org/u/DanielC)\
**Replies:** 2\
**Last updated:** [August 13, 2025, 9:23am UTC](https://forums.swift.org/t/swiftdata-context-is-empty-after-saving/75091 "2025-08-13T09:23:37Z")

</div>

Hi there, Super beginner in Swift and SwiftData here. I created a simple project to import data from a .json file into a Swift model using SwiftData. The process involves loading and decoding the .json file, then saving…

---

## [ModelActor + SwiftData](https://forums.swift.org/t/modelactor-swiftdata/80611)

<div class="topic-metadata">

**Author:** [@NicolasL](https://forums.swift.org/u/NicolasL)\
**Replies:** 1\
**Last updated:** [July 18, 2025, 12:01pm UTC](https://forums.swift.org/t/modelactor-swiftdata/80611 "2025-07-18T12:01:13Z")

</div>

Hello all I have a question with ModelActor, this my model, I have N conversation and we have N User @Model class Conversation { @Attribute(.unique) var id: UUID var name: String var user: User va…

---

## [How to safely apply SortDescriptor(\\.sortOrder) with Swift 6 Concurrency and @Model](https://forums.swift.org/t/how-to-safely-apply-sortdescriptor-sortorder-with-swift-6-concurrency-and-model/80911)

<div class="topic-metadata">

**Author:** [@Luk3](https://forums.swift.org/u/Luk3)\
**Replies:** 6\
**Last updated:** [July 8, 2025, 5:42am UTC](https://forums.swift.org/t/how-to-safely-apply-sortdescriptor-sortorder-with-swift-6-concurrency-and-model/80911 "2025-07-08T05:42:02Z")

</div>

Hi all, I’m working on a SwiftUI app using SwiftData and recently enabled Swift 6 in my project. After doing so, I started getting the following error when using a SortDescriptor with a key path: Type 'ReferenceWritabl…

---

## [How to use a Predicate on optional to-many properties (as required by CloudKit in SwiftData)?](https://forums.swift.org/t/how-to-use-a-predicate-on-optional-to-many-properties-as-required-by-cloudkit-in-swiftdata/80536)

<div class="topic-metadata">

**Author:** [@bryan](https://forums.swift.org/u/bryan)\
**Replies:** 0\
**Last updated:** [June 18, 2025, 5:20am UTC](https://forums.swift.org/t/how-to-use-a-predicate-on-optional-to-many-properties-as-required-by-cloudkit-in-swiftdata/80536 "2025-06-18T05:20:05Z")

</div>

Fails with "to-many key not allowed here" // parent.children?.contains(where: { $0.name == "Abbiejean" // }) != nil parent.children.flatMap { children in children.contains(where: {…

---

## [SwiftData debugging tool](https://forums.swift.org/t/swiftdata-debugging-tool/79504)

<div class="topic-metadata">

**Author:** [@alex566](https://forums.swift.org/u/alex566)\
**Replies:** 4\
**Last updated:** [June 5, 2025, 9:39am UTC](https://forums.swift.org/t/swiftdata-debugging-tool/79504 "2025-06-05T09:39:30Z")

</div>

Hello everyone! I’m working on a tool that is dedicated to debugging SwiftData databases. It’s based on Core Data, but trying to mimic the style and match the information with SwiftData as much as possible. Even fil…

---

## [Sorting SwiftData objects](https://forums.swift.org/t/sorting-swiftdata-objects/79650)

<div class="topic-metadata">

**Author:** [@danusrasmus](https://forums.swift.org/u/danusrasmus)\
**Replies:** 0\
**Last updated:** [May 3, 2025, 9:34am UTC](https://forums.swift.org/t/sorting-swiftdata-objects/79650 "2025-05-03T09:34:57Z")

</div>

I am at day 85 of the HackingWithSwiftUI challenge and I just can't get the sorting of the Prospect objects to work. I even looked back to day 58 when Paul Hudson explained how to change the sorting parameters for the Sw…

---

## [SwiftData - disable Persistent History Tracking](https://forums.swift.org/t/swiftdata-disable-persistent-history-tracking/79433)

<div class="topic-metadata">

**Author:** [@VladFein](https://forums.swift.org/u/VladFein)\
**Replies:** 2\
**Last updated:** [April 22, 2025, 12:06am UTC](https://forums.swift.org/t/swiftdata-disable-persistent-history-tracking/79433 "2025-04-22T00:06:18Z")

</div>

Hello, I am building a pretty large database (~40MB) to be used in my SwiftData iOS app as read-only. While inserting and updating the data, I noticed a substantial increase in size (+ ~10MB). A little digging pointed…

---

## [@Query using Predicate and DateComponents (multidatecomponents)](https://forums.swift.org/t/query-using-predicate-and-datecomponents-multidatecomponents/79378)

<div class="topic-metadata">

**Author:** [@JELI](https://forums.swift.org/u/JELI)\
**Replies:** 1\
**Last updated:** [April 21, 2025, 2:14am UTC](https://forums.swift.org/t/query-using-predicate-and-datecomponents-multidatecomponents/79378 "2025-04-21T02:14:42Z")

</div>

I am trying to build a CRUD app using a multidatepicker. The Apple documentation for multidatepicker uses Set\<DateComponents\> = \[ \] The problem is how to retrieve records for the current date. The debugger has the fo…

---

## [SwiftData - Is there a reason not to wrap an existing struct in a \`@Model\`'ed class?](https://forums.swift.org/t/swiftdata-is-there-a-reason-not-to-wrap-an-existing-struct-in-a-model-ed-class/79065)

<div class="topic-metadata">

**Author:** [@carlynorama](https://forums.swift.org/u/carlynorama)\
**Replies:** 0\
**Last updated:** [April 3, 2025, 2:59pm UTC](https://forums.swift.org/t/swiftdata-is-there-a-reason-not-to-wrap-an-existing-struct-in-a-model-ed-class/79065 "2025-04-03T14:59:54Z")

</div>

ETA: Apologies! SwiftData like SwiftUI is probably better to take over to the apple dev forums! Got thrown by the name there for second. New to SwiftData, but I was thinking of adding it to a small project as a persist…

---

## [CompoundPredicate: A small library to combine Predicates](https://forums.swift.org/t/compoundpredicate-a-small-library-to-combine-predicates/70688)

<div class="topic-metadata">

**Author:** [@NoahKamara](https://forums.swift.org/u/NoahKamara)\
**Replies:** 7\
**Last updated:** [March 12, 2025, 9:19pm UTC](https://forums.swift.org/t/compoundpredicate-a-small-library-to-combine-predicates/70688 "2025-03-12T21:19:17Z")

</div>

Hello Swift Community, Lately, I've been increasingly frustrated with the limitations of Predicates in Swift, especially when it comes to combining them, unlike NSPredicate. The documentation on this topic has been rath…

---

## [SwiftData model self question](https://forums.swift.org/t/swiftdata-model-self-question/78027)

<div class="topic-metadata">

**Author:** [@jackbullen](https://forums.swift.org/u/jackbullen)\
**Replies:** 2\
**Last updated:** [February 22, 2025, 8:04pm UTC](https://forums.swift.org/t/swiftdata-model-self-question/78027 "2025-02-22T20:04:43Z")

</div>

Here is a simple setup that demonstrates my issue. Problem is the prev attribute is not correct. I believe it is because when I change previousNode, this modifies the existing Node objects. import SwiftUI import SwiftDa…

---

## [Problem with list selection storage in SwiftData. Possible SwiftData relationship needed?](https://forums.swift.org/t/problem-with-list-selection-storage-in-swiftdata-possible-swiftdata-relationship-needed/77943)

<div class="topic-metadata">

**Author:** [@anders7](https://forums.swift.org/u/anders7)\
**Replies:** 0\
**Last updated:** [February 18, 2025, 3:55pm UTC](https://forums.swift.org/t/problem-with-list-selection-storage-in-swiftdata-possible-swiftdata-relationship-needed/77943 "2025-02-18T15:55:31Z")

</div>

Hi everyone. I'm just a beginner to Swift and I have encountered a problem with an app that I am building. The app can save School Subjects. In addsubjectview there is an option to select which terms/semesters the subjec…

---

## [SwiftData enum No exact matches in call to instance method 'setValue' error](https://forums.swift.org/t/swiftdata-enum-no-exact-matches-in-call-to-instance-method-setvalue-error/71682)

<div class="topic-metadata">

**Author:** [@syclonefx](https://forums.swift.org/u/syclonefx)\
**Replies:** 1\
**Last updated:** [February 4, 2025, 9:01pm UTC](https://forums.swift.org/t/swiftdata-enum-no-exact-matches-in-call-to-instance-method-setvalue-error/71682 "2025-02-04T21:01:12Z")

</div>

I'm getting an "No exact matches in call to instance method 'setValue'" error for a property that has a enum as a value. How do I fix this? Any help would be appreciated. enum FluidUnit: CaseIterable, Identifiable { …

---

## [Sorting of Date objects in ForEach loop](https://forums.swift.org/t/sorting-of-date-objects-in-foreach-loop/77592)

<div class="topic-metadata">

**Author:** [@anders7](https://forums.swift.org/u/anders7)\
**Replies:** 6\
**Last updated:** [February 2, 2025, 9:03am UTC](https://forums.swift.org/t/sorting-of-date-objects-in-foreach-loop/77592 "2025-02-02T09:03:08Z")

</div>

Hi all, I am a complete newbie here. Probably an easy fix but I cannot get this to work: I am trying to sort an array of Time objects so that in the UI the subject that happens first appears first. Here is the code: im…

---

## [Repeated SwiftData error in finding currently active container](https://forums.swift.org/t/repeated-swiftdata-error-in-finding-currently-active-container/68545)

<div class="topic-metadata">

**Author:** [@PeterSteiner](https://forums.swift.org/u/PeterSteiner)\
**Replies:** 3\
**Last updated:** [January 21, 2025, 5:46am UTC](https://forums.swift.org/t/repeated-swiftdata-error-in-finding-currently-active-container/68545 "2025-01-21T05:46:37Z")

</div>

Hello everybody, I am a German math student trying to build some super simple educational apps. I always run into the same problem: Error message: Thread 1: Fatal error: failed to find a currently active container for C…

---

## [Swift Data usage with global container and ephemeral contexts](https://forums.swift.org/t/swift-data-usage-with-global-container-and-ephemeral-contexts/76914)

<div class="topic-metadata">

**Author:** [@urip](https://forums.swift.org/u/urip)\
**Replies:** 0\
**Last updated:** [December 30, 2024, 1:58am UTC](https://forums.swift.org/t/swift-data-usage-with-global-container-and-ephemeral-contexts/76914 "2024-12-30T01:58:04Z")

</div>

I’m currently using Swift Data with the following pattern: ModelContainer is initialized once in the global scope as a global variable. The container is injected into my app using .modelContainer(container) and accesse…

---

## [SwiftData Predicate does not handle protocol witness?](https://forums.swift.org/t/swiftdata-predicate-does-not-handle-protocol-witness/68256)

<div class="topic-metadata">

**Author:** [@Terje](https://forums.swift.org/u/Terje)\
**Replies:** 3\
**Last updated:** [December 19, 2024, 9:30am UTC](https://forums.swift.org/t/swiftdata-predicate-does-not-handle-protocol-witness/68256 "2024-12-19T09:30:40Z")

</div>

Hi, I have a protocol Record : PersistentModel and my model conforms to this protocol. protocol Record : PersistentModel { var title: String { get } } @Model final class TestModel { let title: String } extensi…

---

## [Connecting the dots: Vapor and SwiftData](https://forums.swift.org/t/connecting-the-dots-vapor-and-swiftdata/66698)

<div class="topic-metadata">

**Author:** [@torstenbernhard](https://forums.swift.org/u/torstenbernhard)\
**Replies:** 12\
**Last updated:** [December 17, 2024, 6:15am UTC](https://forums.swift.org/t/connecting-the-dots-vapor-and-swiftdata/66698 "2024-12-17T06:15:31Z")

</div>

For work with external databases, there are many packages available (Vapour, Fluent, Postgres etc.). There are also excellent tutorials, showing how to use Vapor in SwiftUI/Core Data apps. The upcoming SwiftData simpli…

---

## [SwiftData SchemaMigrationPlan and VersionedSchema not Sendable](https://forums.swift.org/t/swiftdata-schemamigrationplan-and-versionedschema-not-sendable/75731)

<div class="topic-metadata">

**Author:** [@GuyB](https://forums.swift.org/u/GuyB)\
**Replies:** 2\
**Last updated:** [November 1, 2024, 9:03am UTC](https://forums.swift.org/t/swiftdata-schemamigrationplan-and-versionedschema-not-sendable/75731 "2024-11-01T09:03:11Z")

</div>

I am writing a new app from scratch using swift6 and SwiftData, and so far have been pretty happy not to run into errors or warnings about unsafe code. Today I started to add Schema versioning to my SwiftData model and …

---

## [Type Eraser for Containers](https://forums.swift.org/t/type-eraser-for-containers/75710)

<div class="topic-metadata">

**Author:** [@nikolaknez](https://forums.swift.org/u/nikolaknez)\
**Replies:** 3\
**Last updated:** [October 31, 2024, 8:39am UTC](https://forums.swift.org/t/type-eraser-for-containers/75710 "2024-10-31T08:39:14Z")

</div>

Hi all, Is this allowed: environment(\\.container, MyContainer() as Any) While injecting Model container into the environment we use Type . Is there any universal injection type that can inject container as set of any …

[Next page](https://forums.swift.org/tag/swiftdata/854.md?match_all_tags=true&page=1&tags%5B%5D=swiftdata)
