SwiftData & CloudKit: See How To Add Syncing In Your Apps | SwiftData Tutorial | #15

  Рет қаралды 2,707

tundsdev

tundsdev

Күн бұрын

Пікірлер: 43
@holycrosscv
@holycrosscv 7 ай бұрын
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!
@tundsdev
@tundsdev 7 ай бұрын
Glad it was helpful!
@nigelhamilton6359
@nigelhamilton6359 25 күн бұрын
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??
@MrBionik6
@MrBionik6 7 ай бұрын
Awesome man, really nice tutorial. I was waiting for this one ❤
@tundsdev
@tundsdev 7 ай бұрын
Glad you enjoyed it 🤝
@gavinjerman
@gavinjerman 7 ай бұрын
Great stuff, thanks.
@tundsdev
@tundsdev 7 ай бұрын
Glad you enjoyed it
@javierdejorgesanchez-garni1158
@javierdejorgesanchez-garni1158 7 ай бұрын
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?
@tundsdev
@tundsdev 7 ай бұрын
Great to hear, you shouldn’t have to no. But there is no harm in doing it just so you don’t forget
@javierdejorgesanchez-garni1158
@javierdejorgesanchez-garni1158 7 ай бұрын
Great. It is because I did and is not sync. Incredible mystery’s of iCloud… 😂 thanks again 👍
@UltimateGameDeveloper
@UltimateGameDeveloper 5 ай бұрын
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?
@tundsdev
@tundsdev 5 ай бұрын
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:)
@UltimateGameDeveloper
@UltimateGameDeveloper 5 ай бұрын
@@tundsdevhow would you write it on code tho I understand the logic I just don’t know how to write it in in code
@sportguy8135
@sportguy8135 5 ай бұрын
@@tundsdev I tried what you said but it still syncs
@tundsdev
@tundsdev 5 ай бұрын
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
@tundsdev
@tundsdev 4 ай бұрын
Here's a sample project you could follow to get some ideas github.com/tunds/IAPSampleApp/tree/main/IAPSampleApp
@tvidenov
@tvidenov 5 ай бұрын
Thanks you @tundsdev for the great explanation. Can you give us a link to the code as well? Is currently missing from the description.
@kazuya2481
@kazuya2481 3 ай бұрын
Does Apple support public and shared data from ios18?
@grin_phi
@grin_phi 7 ай бұрын
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?
@tundsdev
@tundsdev 7 ай бұрын
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_phi
@grin_phi 7 ай бұрын
Indeed, but once you have checked (on a new device) could we not set a parameter that prevents future checks on that device?
@tundsdev
@tundsdev 7 ай бұрын
@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_phi
@grin_phi 7 ай бұрын
@@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!
@nigelhamilton6807
@nigelhamilton6807 21 күн бұрын
Is it possible to download the source code? Thanks.
@play365alltime
@play365alltime 7 ай бұрын
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?
@tundsdev
@tundsdev 7 ай бұрын
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.
@Echaront
@Echaront 2 ай бұрын
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?
@iLoveAppl3947
@iLoveAppl3947 3 ай бұрын
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
@tundsdev
@tundsdev 3 ай бұрын
Hahaha I got you!
@edwardsanchez5278
@edwardsanchez5278 7 ай бұрын
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?
@tundsdev
@tundsdev 7 ай бұрын
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
@holycrosscv
@holycrosscv 6 ай бұрын
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!
@tundsdev
@tundsdev 6 ай бұрын
Interesting, I've not come across this but I'll keep an eye out on what you've said.
7 ай бұрын
👍👍👍
@tundsdev
@tundsdev 7 ай бұрын
Glad you’re enjoying it
@rafaelplinio6527
@rafaelplinio6527 7 ай бұрын
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?
@tundsdev
@tundsdev 7 ай бұрын
It should have anything in the cloudkit db, so it should just fetch the model data from the cloudkit dashboard
@holycrosscv
@holycrosscv 7 ай бұрын
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
@tundsdev
@tundsdev 7 ай бұрын
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.
@holycrosscv
@holycrosscv 7 ай бұрын
@@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!!
@holycrosscv
@holycrosscv 7 ай бұрын
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!
CloudKit - Intro, Pricing, Terms, & Definitions
17:26
Sean Allen
Рет қаралды 22 М.
ПРИКОЛЫ НАД БРАТОМ #shorts
00:23
Паша Осадчий
Рет қаралды 5 МЛН
So Cute 🥰
00:17
dednahype
Рет қаралды 58 МЛН
How Strong is Tin Foil? 💪
00:26
Preston
Рет қаралды 78 МЛН
Teaching a Toddler Household Habits: Diaper Disposal & Potty Training #shorts
00:16
SwiftData CloudKit Sync - The Complete Guide
1:02:38
azamsharp
Рет қаралды 7 М.
Why I don't do MVVM anymore
10:56
Flo writes Code
Рет қаралды 7 М.
SwiftData Debugging The Easy Way | SwiftData Tutorial | #11
14:03
CoreData в Swift. Разработка приложений
47:55
simpleDEV. Swift c нуля до бесконечности
Рет қаралды 9 М.
Setup CloudKit in SwiftUI project and get user info | Advanced Learning #21
33:02
SwiftData Basics in 15 minutes
15:18
CodeWithChris
Рет қаралды 45 М.
ПРИКОЛЫ НАД БРАТОМ #shorts
00:23
Паша Осадчий
Рет қаралды 5 МЛН