I have an app that has a watch component. Both watch and phone have the same SwiftData Model for persisting data. I’ve been searching on how to have the data that the user stores on the watch able to be sent to the phone so they can have it on their phone for comparison. Hope that makes sense. I’m a relative newbie but have learned a lot through people like you.
Hey. I feel like you want to enable App Groups on your SwiftData model to share the data between two devices. I’d look into using app groups with SwiftData 👌🏾
@@tundsdev, if we are changing only one model, should we include all models in the migration or just the one? I am getting a crazy error "Cannot use staged migration with an unknown coordinator model version." and not sure what else to try!
@dmacharo You need to copy everything over, migrations can be a bit flaky in swiftdata i’ve realised even adding a transformable property or enums can make your app crash… So for now i’d make the models like for like 👌🏾
Yh you should be able too, you'd just have to enable icloud syncing on your container in your future app release and the schemas you have at that time would then by synced to icloud. You can check out the icloud vid on ym channel too
Thank you, very helpful! Could you make a video on how to implement a fully working subscription just with StoreKit 2 and the new SwiftUI SubscriptionStoreView?
This is very useful, thank you. A question: when it comes to adding a new property like "isArchived" and "isFlagged", wouldn't automatic migration automatically set such values to false, rather than nil? Cheers.
Thanks & it depends on the type. If it was optional then yh it can be nil. But its non optional you have to add a default value. So it would be whatever you set it can’t assign a value to non optional automatically
@@tundsdev Since there is already a default value, why do we still need to set the value in the database in didMigrate? If null values are an issue, the line context.fetch(FetchDescriptor()) would have already caused a crash.
Hey, love you vids: ) Have you considered doing a video explaining the sample code project Backyard Birds from Apple? I'd love to get your take on why the app is setup the way it is: - multiple ViewModifiers - instance of the DataGeneration - Account setup - StoreKit I'm especially interested in what exactly happens, when the app is launched for the first time and how the subsequent app launches are handled. Take care : )
Yes! Apple has multiple videos, where they explain things like storekit or widgets using Backyard Birds. However, there aren't any good resources on how the app actually works and why certain design decision were made@@tundsdev
Great video, as always🔥! One question about ToDosSchemaV3: do we need to keep the @Attribute(originalName: "timestamp")? Renaming was already taken care of in V2…
So this isn't actually the case you do need this Attribute, I just tested this out in a different scenario and the app crashed for me when i added another migration plan so i'd leave this in place
Thank you for this great video. A question on your versioning: Even though your renaming of ‘timestamp’ to ‘due date’ is small, it is a breaking change. If I’m running the app on two devices, and I update one of them to the latest version and run it, then the MySQL database will have the renamed column/property. The other device will or should fail (since it can’t find ‘timestamp’). Ideally, the other one would get an exception like ‘you must upgrade to the latest version before running this app’. Do you know if changing major or minor versions will prevent incompatible versions from accessing the database after it’s upgraded?
👋🏾 technically it shouldn’t be a problem since this isn’t like MySQL. The persistent storage isn’t on a server its local to the device so you’d be ok using the app until you updated it to a later version. It’s only when you update the app the migration would happen, and this then would perform either a lightweight or heavyweight migration for you 👌🏾
No cap one of THE best tutorials on swiftdata migration/versioning
Best series on Tube...💯🔥 thanks a lot Tuns 🥇
DUDE! Thank you SO much for this video so many other tutorials do not address handling multiple models!
Glad it helped!
Excellent video. No fluff; all value 👌
Glad you enjoyed it!
Hey mate, thanks for the tutorial, finally got a better understanding about Migration which been struggling. Cheers!
Glad it helped!
I have an app that has a watch component. Both watch and phone have the same SwiftData Model for persisting data. I’ve been searching on how to have the data that the user stores on the watch able to be sent to the phone so they can have it on their phone for comparison. Hope that makes sense. I’m a relative newbie but have learned a lot through people like you.
Hey. I feel like you want to enable App Groups on your SwiftData model to share the data between two devices. I’d look into using app groups with SwiftData 👌🏾
Thank you so much for all you done, it's very helpful for me! Liked, subscribed and commented!
Man this is absolute gold! Thanks heaps!
Glad you enjoy it 👌🏾
@@tundsdev, if we are changing only one model, should we include all models in the migration or just the one?
I am getting a crazy error "Cannot use staged migration with an unknown coordinator model version." and not sure what else to try!
@dmacharo You need to copy everything over, migrations can be a bit flaky in swiftdata i’ve realised even adding a transformable property or enums can make your app crash…
So for now i’d make the models like for like 👌🏾
Super helpful, thank you!
Glad it was helpful!
Could you do a video on how to do alternate app icons and have the user select which one they want? Great video as always!
Cool idea for sure 👌🏾
Very detailed tutorial 👍
Great video 👍 thanks
Is it possible to migrate while using CloudKit?
Yh you should be able too, you'd just have to enable icloud syncing on your container in your future app release and the schemas you have at that time would then by synced to icloud. You can check out the icloud vid on ym channel too
Subject suggestion: Transferring SwiftData model from watch to phone. I could definitely use a tutorial on that one!
Can you explain this one a bit more?
Thank you, very helpful! Could you make a video on how to implement a fully working subscription just with StoreKit 2 and the new SwiftUI SubscriptionStoreView?
It’s already in the works 👀, I really appreciate the support and don’t forget to subscribe & share the channel 🙏🏾
You had me at 2Pac and lost me at McDonald’s 😂
McDonalds is easily the creme de la crem of fast food 🤷🏾♂️
This is very useful, thank you.
A question: when it comes to adding a new property like "isArchived" and "isFlagged", wouldn't automatic migration automatically set such values to false, rather than nil?
Cheers.
Thanks & it depends on the type. If it was optional then yh it can be nil. But its non optional you have to add a default value. So it would be whatever you set it can’t assign a value to non optional automatically
@@tundsdev Cheers.
@@tundsdev Since there is already a default value, why do we still need to set the value in the database in didMigrate? If null values are an issue, the line context.fetch(FetchDescriptor()) would have already caused a crash.
Hey, love you vids: ) Have you considered doing a video explaining the sample code project Backyard Birds from Apple?
I'd love to get your take on why the app is setup the way it is:
- multiple ViewModifiers
- instance of the DataGeneration
- Account setup
- StoreKit
I'm especially interested in what exactly happens, when the app is launched for the first time and how the subsequent app launches are handled.
Take care : )
I’ve not actually, but do you mean like a code review? It’s something i could do & consider for sure 👌🏾
Yes! Apple has multiple videos, where they explain things like storekit or widgets using Backyard Birds. However, there aren't any good resources on how the app actually works and why certain design decision were made@@tundsdev
Cool for sure i’ll look into it, great suggestion 👌🏾
Great video, as always🔥! One question about ToDosSchemaV3: do we need to keep the @Attribute(originalName: "timestamp")? Renaming was already taken care of in V2…
Thanks & probably not since it’s already been renamed in V2 like you say 👌🏾, that’s what I get for copying and pasting code 😂
So this isn't actually the case you do need this Attribute, I just tested this out in a different scenario and the app crashed for me when i added another migration plan so i'd leave this in place
@@tundsdev thanks so much for your additional testing and follow up 💯
Thank you for this great video. A question on your versioning: Even though your renaming of ‘timestamp’ to ‘due date’ is small, it is a breaking change. If I’m running the app on two devices, and I update one of them to the latest version and run it, then the MySQL database will have the renamed column/property. The other device will or should fail (since it can’t find ‘timestamp’). Ideally, the other one would get an exception like ‘you must upgrade to the latest version before running this app’. Do you know if changing major or minor versions will prevent incompatible versions from accessing the database after it’s upgraded?
👋🏾 technically it shouldn’t be a problem since this isn’t like MySQL. The persistent storage isn’t on a server its local to the device so you’d be ok using the app until you updated it to a later version.
It’s only when you update the app the migration would happen, and this then would perform either a lightweight or heavyweight migration for you 👌🏾
I've been getting an exception "Thread 1: "The current model reference and the next model reference cannot be equal."
Does anyone have a suggestion?
My Application Support is Empty after adding some records.