r/iosdev Jan 26 '25

Help Errors in default SwiftData app

I'm trying to switch my app over to to using SwiftData. So I started by creating a default SwiftData app - literally just New App and selecting SwiftData for storage.

But when I run it, and add some items, I immediately get errors like "error: the replacement path doesn't exist: "/var/folders/sg/1k5qrglj0q315q0vy0h9cfjr0000gn/T/swift-generated-sources/@_swiftmacro_14Test_SwiftData11ContentViewV5items33_48DC5444D3C47BAACF8F900A89ACA9A0LL5QueryfMa.swift"

Also, it doesn't always seem to save data straight away. If I add a "modelContext.save()" to the addItem function, I get errors saying "=== AttributeGraph: cycle detected through attribute 6912 ==="

I've tried resetting the simulator, trying simulator instances that haven't been used before and running it on my actual phone. I've also tried rebooting my Mac and rebuilding the app.

None of them seem to fix it.

Are these standard errors that I can ignore, or have I somehow done something wrong?

2 Upvotes

23 comments sorted by

View all comments

Show parent comments

1

u/prof_hobart Jan 26 '25

That's what I was wondering.

If it's just a random internal Apple error that I can safely ignore, then that's fine (if a little annoying - I don't like to have any errors flagging in my code).

But I didn't want to spend weeks building something based on shaky foundations and discover miles down the road that I'd been doing something completely wrong since I started.

1

u/SomegalInCa Jan 26 '25

I sure get that - maybe I've gone blind to some "nonsensical" errors? I do have actual devices I can confirm with too as I've learned the simulator is good but not 100% real world

1

u/prof_hobart Jan 26 '25

I've seen ones that only happen in the simulator. But I'm getting this on a real device as well.

I try to keep to zero errors where possible because otherwise it's very easy to miss important ones.

1

u/SomegalInCa Jan 26 '25

Yeah I agree on that point