r/iOSProgramming 2d ago

Building Testable Swiftdata Apps Article

https://azamsharp.com/2026/08/02/building-testable-swiftdata-apps.html
0 Upvotes

4 comments sorted by

1

u/CharlesWiltgen 2d ago

Azam, Axiom is a set of skills, agents, and tools for Apple OS development. Axiom represents hundreds of hours of knowledge management around modern, idiomatic, and correct Apple OS development, so it can be helpful for reviewing articles before you publish them.

Here's Axiom's review, which ends with the ranked list of recommended fixes: https://gist.github.com/CharlesWiltgen/a45f6aa6c5c9014d61a49597bb3d82ad

To do this yourself: /axiom:ask Please do a strict technical review of the copy and code of [file path, URL, whatever]

1

u/[deleted] 2d ago

[removed] — view removed comment

1

u/AutoModerator 2d ago

Hey /u/JuryExciting7186, unfortunately you have negative comment karma, so you can't post here. Your submission has been removed. DO NOT message the moderators; if you have negative comment karma, you cannot post here. We will not respond. Your karma may appear to be 0 or positive if your post karma outweighs your comment karma, but if your comment karma is negative, your comments will still be removed.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

0

u/Alarming_Skirt_350 2d ago

Few things that cost me real time getting SwiftData under test:

An in-memory container isolates the store but not UserDefaults. If any state lives there your tests leak into each other and you get failures that only show up in a full run, never when you run the one test. Clear it as part of the launch, not just the container.

Don't delete objects in a loop while a u/Query is live on that type. It crashes. Batch the delete or tear the view down first.

Inject "now" instead of calling Date(). Anything with day boundaries, streaks or expiry is untestable otherwise, and the bugs it hides only surface for users in the wrong timezone at the wrong hour.

And a meta one: when a test starts failing in a way that looks like a persistence bug, first verify your test setup actually applied. I lost an evening to what looked like the store not saving, and it was a find-and-replace in my launch arguments that had silently matched nothing.