Thanks! This is a brilliant CloudKit course and I really appreciate it. There were a couple of catches that always trip me up, and your explanation nailed it! Thanks!
@tundsdev8 ай бұрын
Glad it was helpful!
@MrBionik68 ай бұрын
Awesome man, really nice tutorial. I was waiting for this one ❤
@tundsdev8 ай бұрын
Glad you enjoyed it 🤝
@UltimateGameDeveloper7 ай бұрын
great vid really helped but i have a question how would you make the cloud kit only work for your user if he payed for it?
@tundsdev7 ай бұрын
So when you configure your container you can control whether syncing via the ModelConfiguration. So you can set an enum to none, glad it helped too! developer.apple.com/documentation/swiftdata/modelconfiguration/init(_:schema:isstoredinmemoryonly:allowssave:groupcontainer:cloudkitdatabase:)
@UltimateGameDeveloper7 ай бұрын
@@tundsdevhow would you write it on code tho I understand the logic I just don’t know how to write it in in code
@sportguy81356 ай бұрын
@@tundsdev I tried what you said but it still syncs
@tundsdev6 ай бұрын
Here's a super simple example in a gist, you still need to write your own logic to find out if a user has paid or not using StoreKit2 gist.github.com/tunds/535a07293766b6fa2d4171ff88625a4d
@tundsdev6 ай бұрын
Here's a sample project you could follow to get some ideas github.com/tunds/IAPSampleApp/tree/main/IAPSampleApp
@javierdejorgesanchez-garni11588 ай бұрын
Thanks a lot, this is the only place that goes into deep detail about this matter. One question, for TestFlight do you need to deploy it in production mode as well?
@tundsdev8 ай бұрын
Great to hear, you shouldn’t have to no. But there is no harm in doing it just so you don’t forget
@javierdejorgesanchez-garni11588 ай бұрын
Great. It is because I did and is not sync. Incredible mystery’s of iCloud… 😂 thanks again 👍
@nigelhamilton63592 ай бұрын
Really great tutorial. Thank-you! I was wondering though... If a user started the app with poor or no internet signal, such that it found none of the restored data in CloudKit, and so then added the data in the app, when the signal was restored, would you end up with duplicates? Perhaps the next launch would remove the duplicates??
@gavinjerman8 ай бұрын
Great stuff, thanks.
@tundsdev8 ай бұрын
Glad you enjoyed it
@jutublizard18 күн бұрын
Is it better to sync the data using CloudKit or use own storage api /server?
@tvidenov7 ай бұрын
Thanks you @tundsdev for the great explanation. Can you give us a link to the code as well? Is currently missing from the description.
@grin_phi8 ай бұрын
You didn't disappoint with this one Tunds! Helped me heaps. Quick Q. Seems like the code to check if data already exists runs every time the app launches? Any reason not to wrap it in userdefaults/@appstroage first run conditional?
@tundsdev8 ай бұрын
Thanks, the problem is it was using userdefaults before. But with cloudkit and swiftdata it will automatically sync and changes that you have in your cloud storage so on every fresh new device if you have prefilled data it will sync and recreate duplicates. So if you have pre filled data you have to handle this manually with icloud I found
@grin_phi8 ай бұрын
Indeed, but once you have checked (on a new device) could we not set a parameter that prevents future checks on that device?
@tundsdev8 ай бұрын
@grin_phi nope, because you wouldn’t know on a new device. That’s the issue the new device has no awareness of the user defaults. Even if you set a flag after the checks you’d still need to try to find the data in cloudkit before you set any flags
@grin_phi8 ай бұрын
@@tundsdev I think we got crossed wires - each new device must check for cloudkit contents, but on each device, that check (in my case) only needs to be done once, so I suppress it with a local flag. Nevertheless, your video was a huge help!
@kazuya24814 ай бұрын
Does Apple support public and shared data from ios18?
@Echaront3 ай бұрын
Hey @tundsdev! Great tutorial! I'm on Xcode 16 beta and I'm getting a "Extra trailing closure passed in call" error (18:10 of the video) on: func fetchItems( with query: CKQuery) async throws -> [CKRecord] { return try await withCheckedThrowingContinuation{ continuation in fetchItems(with: query) { result in continuation.resume(with: result) } } } I am unable to find any "Async wrapper" options in the Editor menu. Any suggestions?
@play365alltime8 ай бұрын
Awesome tutorial as always. I have a question though, I realise the CloudKit takes a huge time to sync. I mean I want to use that for syncing data between my Watch app and iPhone app, but the CloudKit just doesn't sync for a long time, sometimes I need to wait for several hours. I end up using the transferUserInfo again. (which has size limitation and so complicated) Do you think there are any ways to fix that?
@tundsdev8 ай бұрын
Glad you enjoyed it, unless you build your own custom sync wrapper. I’ve found it can be hit and miss for when you can get back a successful sync. Sometimes it’s super quick for me though.
@rafaelplinio65278 ай бұрын
I have a question: if my app with swiftdata + cloudkit is working fine, with entries and everything.Then I delete it and download it again from the app store. Will it still have the previous data (the entries) since it has cloudkit in it or will it be completed new without any entries?
@tundsdev8 ай бұрын
It should have anything in the cloudkit db, so it should just fetch the model data from the cloudkit dashboard
@edwardsanchez52788 ай бұрын
Thanks for the great video! I’m just starting out so please bear with me. But the code to check for dupes and all seems so complicated, it’s amazing that that’s all necessary. Does it prevent content from being downloaded from iCloud to begin with? Checking for duplication before it even downloads it? Or does it just check for duplication after it already downloaded? If so, can one not do a check on your model for any duplicate items on app launch / on a timer, and delete those? If syncing photos that solution will waste time and bandwidth but if you’re just dealing with small data like text, maybe it’s ok? I wish CloudKit / SwiftData just handled this stuff for you to begin with so no boiler plate would be allowed - who wants duplicate data?
@tundsdev8 ай бұрын
Hey man, like I said in the video this is just something I whipped up on the spot to solve this problem. There’s probs plenty of other alternatives. In your case i dont think you need to do this since i only do it for prefilled data which it sounds like you’re not doing
@nigelhamilton68072 ай бұрын
Is it possible to download the source code? Thanks.
@holycrosscv8 ай бұрын
Hi, pre-filling data in Development mode seems to work fine, but when switched over to Production, the data pre-fill all over again. Delating on the device AND in iCloud still creates the default data on both items and categories. Any clue why? Thanks. Blessings, --Mark
@tundsdev8 ай бұрын
Hmmm i’ve not come across this, in the examples I tried. As long as I was able to query if the data already existed in cloudkit that prevented me from inserting the data into the modelcontainer. Basically you have to make sure you don’t prefill/insert data if the data is already there in the cloud database.
@holycrosscv8 ай бұрын
@@tundsdev I sent an app off to the App Store and forgot to deploy it to production before it was approved. Doh! I just sent in a Hot Fix, and now that it is deployed, this may be the issue I am dealing with. Thanks!!
@holycrosscv8 ай бұрын
Well, due to the weirdness of iCloud, sending in an update to Apple did nothing to stop the defaults from restoring. Interestingly, though, it is not until the last default Category is deleted before they all restore. The fix was simple enough: just set an AppStorage bool and add a toggle if a user wants to restore the defaults. Thanks again for a great tutorial. It really helped out!
8 ай бұрын
👍👍👍
@tundsdev8 ай бұрын
Glad you’re enjoying it
@holycrosscv8 ай бұрын
Have you noticed that if you add an image to a record CloudKit stops pushing updates to the server? Not sure why. I can understand that the image is not pushed up since it is stored locally, but CloudKit stops pushing updates of records without an image as well. Very strange behavior!
@tundsdev8 ай бұрын
Interesting, I've not come across this but I'll keep an eye out on what you've said.
@xlzhong49563 күн бұрын
how to download this code?
@richardwinters411421 күн бұрын
If you disable the cloud sync in the Settings for your app, all data on that device is lost.
@Spacer-l3j5 ай бұрын
jeez man... how the heck Apple didn't provide a clear explanations on what to do from A to B in SwiftUI ? how are we supposed to know all of this if for example you didn't make this video ? No wonder people choose Firebase sometimes