8. SwiftData CloudKit

Поділитися
Вставка
  • Опубліковано 30 чер 2024
  • This is the 8th and penultimate video in this SwiftData series. In this video we are going to be adding CloudKit capabilities to our app so that all CRUD actions (create read update and delete) are synchronized with all of our devices signed in to the same iCloud account.
    If you want to support my work, you can buy me a coffee :)
    ko-fi.com/stewartlynch
    Table of Contents:
    0:00 Introduction
    1:05 iCloud Setup
    5:11 Required Code Modifications
    8:12 Testing pm Devices
    12:55 CloudKit Console
    16:16 Deploying to Production
    Starter Project Files:
    github.com/StewartLynch/MyBoo...
    or
    github.com/StewartLynch/MyBoo...
    Completed Project:
    github.com/StewartLynch/MyBoo...
    Bezel Application for Device Screen Mirroring
    getbezel.app/?...
    All videos in this Series
    SwiftData: CRUD operations
    • 1. SwiftData CRUD Oper...
    SwiftData: Containers and Mock Data
    • 2. SwiftData Container...
    SwiftData: Dynamic sorting and filtering
    • 3. SwiftData Dynamic S...
    SwiftData: Lightweight Migrations
    • 4. SwiftData Lightweig...
    SwiftData: One to Many Relationships
    • 5. Swift Data One to M...
    SwiftData: Many to Many Relationships
    • 6. Swift Data Many to ...
    App Localizations in Xcode
    • 7. App Localizations
    SwiftData: CloudKit
    • 8. SwiftData CloudKit
    SwiftData Storing Images and Bug Fixes
    • 9. SwiftData Storing I...
    Recommended Resources:
    BigMountain Studio Books
    SwiftUI Views Mastery
    www.bigmountainstudio.com/vie...
    SwiftUI 5 Book Bundle
    www.bigmountainstudio.com/boo...
    Combine Mastery in SwiftUI
    www.bigmountainstudio.com/com...
    Core Data Mastery in SwiftUI
    www.bigmountainstudio.com/cor...
    SwiftUI Animations Mastery
    www.bigmountainstudio.com/ani...
    AppCoda Books
    Beginning iOS 16 Programming with Swift (SwiftUI + UIKit)
    gumroad.com/a/646790611/WihuX
    Beginning iOS 16 Programming with Swift (SwiftUI + UIKit) - Starter
    gumroad.com/a/646790611/mOzKq
    Mastering SwiftUI 4 + Swift Programming for iOS 16 - Professional
    gumroad.com/a/646790611/gjPBw
    Mastering SwiftUI 4 - Starter
    gumroad.com/a/646790611/TyNEz
    Other References:
    Stewart Lynch's UA-cam Channel:
    / @stewartlynch
    Stewart Lynch on Mastodon:
    iosdev.space/@StewartLynch
    Stewart Lynch On Threads:
    @StewartLynch
    Stewart Lynch on X:
    x.com/StewartLynch
    Stewart Lynch on LinkedIn
    / stewartlynch
  • Наука та технологія

КОМЕНТАРІ • 38

  • @patrickabeya
    @patrickabeya 5 місяців тому +3

    What a masterful performance this series has been. Love how you sprinkle useful tips here and there.

  • @timothycbryant
    @timothycbryant 2 місяці тому +1

    I know I commented on an earlier video in this series that I hope WWDC brings us CloudKit sharing, but is it currently possible to use SwiftData in conjunction with CoreData to achieve CloudKit sharing? And if so is this something you would ever consider making an additional video to add to this series? Either way, this is without a doubt the best taught and most complete tutorial on SwiftData that I have seen (with so many non-SwiftData nuggets along the way). This is a masterclass and thank you so much for putting this together!

    • @StewartLynch
      @StewartLynch  2 місяці тому

      I am going to hold off on this until after WWWDC. Thanks for the compliments though.

  • @trevormills
    @trevormills 6 місяців тому +1

    Excellent and very informative tutorial series Stewart. Your teaching style is great, making it easy to absorb - thank you 🙏

  • @Yannemal
    @Yannemal 7 місяців тому +1

    A great introduction to SwiftData and lots of new modifiers for SwiftUI along the way. Enjoyed following along and now I'm reading about Databases in general curious about all things database :for even bigger apps I'd like to attempt )

  • @adrianoramos9471
    @adrianoramos9471 Місяць тому

    That is great material Mr. Lynch! Congrats.

  • @tazman7689
    @tazman7689 7 місяців тому +2

    Great tutorial my friend. I’ve learned a lot.

  • @andrejkling3886
    @andrejkling3886 6 місяців тому +1

    Thank you so much Stewart ...💯🔥 for all your efforts 🇨🇦

  • @olyphotographer
    @olyphotographer 6 місяців тому +3

    Thank you very much! It's a pity that SwiftData currently only supports the private db and not also the shared db as Coredata does. Sharing data with all devices for a user has also some pitfalls. I have an app which creates some default entries as long as the tables are empty (e.g. currencies, countries...) When a user opens the app on two different devices, all entries are being duplicated, that's the normal behavior of CloudKit sync, as long as CloudKit doesn't support unique entries. I had to modify the app so that the user has to press a button to generate the default together with an indication of what can happen.

  • @zackzack7477
    @zackzack7477 4 місяці тому

    my god this was the best tutorial on CloudKit and SwiftData integration

  • @dibergum
    @dibergum 6 місяців тому

    Great video, Stewart! Thank you for all the work you put in to make them. This afternoon I lost all my UA-cam subs and history. Really don't know how that can happen. So I'm resubbing.

    • @dibjr
      @dibjr 6 місяців тому

      It was Google Chrome doing it to me. All is well in Safari.

    • @dibjr
      @dibjr 6 місяців тому

      It turns out it was Google Chrome that made my UA-cam profile disappear. As you can see in this post, all is well with Safari. My solution is to just quit using Chrome for now.

  • @kenturnbull9679
    @kenturnbull9679 6 місяців тому

    Ein anderer(localized 😀) great tutorial. It looks( to me) like CloudKit has more problems than it is worth at this time.

  • @zackzack7477
    @zackzack7477 4 місяці тому

    also if anyone is having issues with data not showing up on their Production environment, try "import Cloudkit" wherever you are importing SwiftData

  • @PeteLorimer
    @PeteLorimer 6 місяців тому

    Thank you Stewart. Your videos always show up just when I’m working through something in your new video.
    Would you consider going over CloudKit’s shared database option sometime? I’d like to find an Apple way of allowing multiple users to share a single database.

    • @StewartLynch
      @StewartLynch  6 місяців тому

      Unfortunately this is not possible with SwiftData

  • @jousufjacob8251
    @jousufjacob8251 6 місяців тому

    Excellent

  • @DavidKoontz
    @DavidKoontz 6 місяців тому

    So the big lesson I gathered - is IF I'm going to use Cloud Kit - start here at this lesson first!
    Glad I watched them all for a first pass.... before starting my own project. I'm wondering if I can uses your Book list as a launching point ? Hmmm I bet so.

    • @StewartLynch
      @StewartLynch  6 місяців тому

      The key is to start here before you have a lot of data entered.

  • @mathewcrovitz7867
    @mathewcrovitz7867 6 місяців тому

    Loving this! I’ve done some minimal work with CloudKit and CoreData…. Wow this is just “magical”, in comparison. I’m sure Apple will enhance it to allow public database, at some point. For some reason, I’m not seeing “my” Zone. I’m only seeing the “_default zone”. I have “Private Database”, “_default Zone (only one available), and I select record type and I see all the tables (records). I can even see the fields. I added the basic index, and when I query, I get no books? How do I get the dashboard to update and show correct zone? Thanks…..

    • @mathewcrovitz7867
      @mathewcrovitz7867 6 місяців тому

      Never mind…. I use a different iCloud Account doing development, than is my AppleID for my Developer Account - DUH!!!! Ha ha

  • @prentissone
    @prentissone 3 місяці тому

    Excellent Series. Allowed me to get my own project up and running. One question/concept. If I wanted to have a reference Schema/Model that would be shared across any user...Example: table of Shoe Sizes. The idea is that I would query those into an Array and then place them in a PickerView. Rather than "hard code" since the sizes might change over time, my idea is that I could have a reference table in the Public Database to @Query from? Is this possible? If so, any ideas to get me started. OR would you recommend a different approach?

    • @StewartLynch
      @StewartLynch  3 місяці тому +1

      Shared CloudKit containers are not supported with SwiftData yet (Maybe coming this year? 🤞)

    • @prentissone
      @prentissone 3 місяці тому

      @@StewartLynch Thank you...perhaps you might add a chapter or two on this series if that becomes available. Either way, thanks again for the great content! Great instructor!! :) I need to now go buy you a coffee

  • @lampree
    @lampree 3 місяці тому

    I already use SwiftData and wanted to adopt CloudKit so my app had a backup in case it is ever reinstalled. Do you know a good way to do this? It seems there isn't a good way to see if you have mirrored all the data from the cloud...

    • @StewartLynch
      @StewartLynch  3 місяці тому

      You can adopt CloudKit, but existing data will not get pushed up to the cloud automatically. You could create your own backup service and I do this a lot. I create a JSON file for all of the data and export any images as JSON and use a ZipFoundation Swift Package to zip up the contents and save to an external directory. I can then reverse the process if I want to restore to that last backup.

  • @DavidKoontz
    @DavidKoontz 6 місяців тому

    Hey Stewart, using the date.distantPast inside a Picker I get a date of Dec 1, 1 (e.g. year 1) but then the picker controls cannot mutate that date - for some unknown reason. Have you seen this problem?

    • @StewartLynch
      @StewartLynch  6 місяців тому

      I fix these issues in the last video

  • @vonner1003
    @vonner1003 Місяць тому

    Hmm. It's telling me that I can't set up icloud as a personal developer. Does any know if that's valid?

    • @StewartLynch
      @StewartLynch  Місяць тому

      Do you have a paid developer account?

  • @mario_luis_dev
    @mario_luis_dev 5 днів тому

    6:52 the “not allowing @Unique properties” part is baffling. I hope they fix this at some point