GO FURTHER, FASTER: Try the Swift Career Accelerator today! >>

SwiftData, CloudKit Sharing between different users

Forums > SwiftUI

Hi All,

I was hoping someone could answer this question as I'm struggling to find anything related. I'm also new to the app development space and SwiftUI so I might not be searching for the right thing.

I recently followed one of Pauls tutorials "Create your first app with SwiftUI and SwiftData" and managed to get something similar working in my app. My app how ever will rely heavily on users being able to share data - for simplicitys sake lets just pretend its a notes app and I want users to be able to add other users to their own notes and have them contribute.

Is this possible using SwiftData and CloudKit? I can find resources about CKShare but I'm not sure if it's compatible with SwiftData?

I'm thinking of just continuing with the app without this functionality at the moment and just concentrating on learning and getting it to work, then coming back at the end and implementing the sharing part.

Thank you

   

I don't know if you saw this: https://www.hackingwithswift.com/quick-start/swiftdata/how-to-sync-swiftdata-with-icloud .. but in the note at the start, Paul mentions that public databases are not yet supported in SwiftData.

I've never implemented the needed NSPersistentCloudKitContainer (for sharing, only personal iCloud sync).. but presume CoreData docs apply here.

   

Thank you. I've since moved over to using core data and cloudkit instead.

   

Yes, it's possible to use SwiftData and CloudKit for sharing data between users. SwiftData and CloudKit can work together, but integrating CKShare for sharing functionality involves additional steps. CKShare lets users share records, and you'll need to manage sharing logic separately from SwiftData.

For now, focusing on getting your app functional is a good approach. You can implement sharing later when you're more comfortable with SwiftUI and CloudKit.

   

Hacking with Swift is sponsored by try! Swift Tokyo.

SPONSORED Ready to dive into the world of Swift? try! Swift Tokyo is the premier iOS developer conference will be happened in April 9th-11th, where you can learn from industry experts, connect with fellow developers, and explore the latest in Swift and iOS development. Don’t miss out on this opportunity to level up your skills and be part of the Swift community!

Get your ticket here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.