#SwiftData/SwiftUI integration

1 messages · Page 1 of 1 (latest)

lofty lichen
#

Does anyone have any experience working with integrating their backend into a front end SwiftUI app? I have previously had my application working quite nicely and am quite far along on a transition to implementing SwiftData and it seems that everything is working except the parsing of my model objects... does anyone have any advice for this? Ive extended my model classes to implement codable but it doesnt seem to work

crystal stirrup
#

Fluent models and Swift Data will not play nicely together

lofty lichen
#

Well Ive got it working since I asked the question in part, what are some considerations youd point out that will be pain points if you wouldnt mind informing me?

crystal stirrup
#

Fluent models rely on property wrappers whereas Swift data is macro based. They're very different things and declare stuff differently

#

The issues aside from that arise from coupling the models across different domains which normally isn't what you want

lofty lichen
#

If the JSON being fed to the front end is what I am processing, how exactly does this affect anything? I am sorry I am totally new to working on this- two months in. I seem to have figured it out pretty well at this point. Would you be interested in seeing my solutions?

crystal stirrup
#

Yeah because there might be some misunderstading so seeing some code would be good

lofty lichen
#

basically you have to decode to a struct model that is the same as ur swift data class model then init a swift data class model with the values of each parameter of your struct

crystal stirrup
#

Right

#

Where does Fluent come into it?

lofty lichen
#

well fluent just feeds json- doesnt seem to be any fluent involvement beyond just defining your models, relationships and migrations. Is there something I should be using fluent for besides that?