SwiftData Migrations | SwiftData Tutorial | #11

Поделиться
HTML-код
  • Опубликовано: 13 окт 2024

Комментарии • 45

  • @homerreal
    @homerreal Месяц назад +1

    No cap one of THE best tutorials on swiftdata migration/versioning

  • @andrejkling3886
    @andrejkling3886 10 месяцев назад +1

    Best series on Tube...💯🔥 thanks a lot Tuns 🥇

  • @robertj1679
    @robertj1679 5 месяцев назад

    DUDE! Thank you SO much for this video so many other tutorials do not address handling multiple models!

    • @tundsdev
      @tundsdev  5 месяцев назад

      Glad it helped!

  • @mullassery
    @mullassery 8 месяцев назад +1

    Excellent video. No fluff; all value 👌

    • @tundsdev
      @tundsdev  8 месяцев назад

      Glad you enjoyed it!

  • @Kontrbandist
    @Kontrbandist 6 месяцев назад +1

    Hey mate, thanks for the tutorial, finally got a better understanding about Migration which been struggling. Cheers!

    • @tundsdev
      @tundsdev  6 месяцев назад +1

      Glad it helped!

  • @maryannadelman4438
    @maryannadelman4438 6 месяцев назад

    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.

    • @tundsdev
      @tundsdev  6 месяцев назад

      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 👌🏾

  • @lib9892
    @lib9892 11 месяцев назад

    Thank you so much for all you done, it's very helpful for me! Liked, subscribed and commented!

  • @dmacharo
    @dmacharo 8 месяцев назад +1

    Man this is absolute gold! Thanks heaps!

    • @tundsdev
      @tundsdev  8 месяцев назад

      Glad you enjoy it 👌🏾

    • @dmacharo
      @dmacharo 8 месяцев назад

      ​@@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!

    • @tundsdev
      @tundsdev  8 месяцев назад +1

      @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 👌🏾

  • @RyanTaylorGT
    @RyanTaylorGT 2 месяца назад

    Super helpful, thank you!

    • @tundsdev
      @tundsdev  2 месяца назад

      Glad it was helpful!

  • @avgeekguy
    @avgeekguy Год назад +2

    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!

    • @tundsdev
      @tundsdev  Год назад +1

      Cool idea for sure 👌🏾

  • @Jake-b4s
    @Jake-b4s 4 месяца назад

    Very detailed tutorial 👍

  •  2 месяца назад

    Great video 👍 thanks
    Is it possible to migrate while using CloudKit?

    • @tundsdev
      @tundsdev  2 месяца назад

      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

  • @MaryAnnAdelman
    @MaryAnnAdelman 6 месяцев назад

    Subject suggestion: Transferring SwiftData model from watch to phone. I could definitely use a tutorial on that one!

    • @tundsdev
      @tundsdev  6 месяцев назад

      Can you explain this one a bit more?

  • @tiIIus
    @tiIIus Год назад

    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?

    • @tundsdev
      @tundsdev  Год назад +2

      It’s already in the works 👀, I really appreciate the support and don’t forget to subscribe & share the channel 🙏🏾

  • @bscheirman
    @bscheirman Год назад +2

    You had me at 2Pac and lost me at McDonald’s 😂

    • @tundsdev
      @tundsdev  Год назад +1

      McDonalds is easily the creme de la crem of fast food 🤷🏾‍♂️

  • @w0mblemania
    @w0mblemania Год назад +1

    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.

    • @tundsdev
      @tundsdev  Год назад

      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

    • @w0mblemania
      @w0mblemania Год назад

      @@tundsdev Cheers.

    • @joe-su3
      @joe-su3 4 месяца назад

      @@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.

  • @aprilzoo9561
    @aprilzoo9561 Год назад +1

    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 : )

    • @tundsdev
      @tundsdev  Год назад +2

      I’ve not actually, but do you mean like a code review? It’s something i could do & consider for sure 👌🏾

    • @aprilzoo9561
      @aprilzoo9561 Год назад

      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

    • @tundsdev
      @tundsdev  Год назад +1

      Cool for sure i’ll look into it, great suggestion 👌🏾

  • @chris_bennett
    @chris_bennett Год назад

    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…

    • @tundsdev
      @tundsdev  Год назад +1

      Thanks & probably not since it’s already been renamed in V2 like you say 👌🏾, that’s what I get for copying and pasting code 😂

    • @tundsdev
      @tundsdev  Год назад

      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

    • @chris_bennett
      @chris_bennett Год назад

      @@tundsdev thanks so much for your additional testing and follow up 💯

  • @mikehimself909
    @mikehimself909 Год назад

    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?

    • @tundsdev
      @tundsdev  Год назад +1

      👋🏾 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 👌🏾

  • @federicoramos
    @federicoramos 3 месяца назад

    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?

  • @Artifismo
    @Artifismo 8 месяцев назад

    My Application Support is Empty after adding some records.