|
Hi, I am designing a simple task manager for a household in SwiftUI. I would like the app to synchronise the content data across the devices of the various users part of the household. To me, this seems like a simple enough process potentially. Which approach is best suitable with the SwiftUI framework? Update: View my response below (2nd post) for a better explanation of my question. Initial post: The data model of the app is very simple at the moment; essentially a collection of tasks that each feature a title, description and assignment to a user. Running the app locally, without synchronisation implemented yet, allows me to make use of the SwiftUI's framework declarative programming and elegant design. I realise that to implement synchronisation with other users' devices unavoidably means I need to implement code and adapt existing code. For years, I have browsed articles and tutorials on data sharing in iOS apps. Options I have explored are Core Data, CloudKit, manual API fetching from server and third-party options like Realm. The underlying, unnamed issue seems to be that SwiftUI is still young and data frameworks don't yet offer an elegant integration. I am looking for an approach that integrates best with SwiftUI's elegance and framework with respect to data propagation (
Concluding, what is in your experience and opinion the best/most elegant or/most viable way, for a simple SwiftUI app, to implement data synchronisation for a simple data model across multiple users' devices? Or, is this not available at this time? (A positive answer here would be equally informative :-) I would love to hear your ideas, Kind regards, Isaiah |
|
Well, that's what separation of concerns is for... right? Your network layer, model, and data processing all can and should be done without worrying about the UI. And while SwiftUI is not just about the UI as a framework, once you understand the passing of data, you really can do anything you want. So essentially what I am saying is: Choose the sync option that you have access to and are comfortable with. Learn (if you haven't already) how to pass data around with SwiftUI. and just implement them separately. Now if you want resouorces I would strongly recommend you check out Donny Wals website and his book: Practical Combine which is where most of the @Observable etc... are from 😉 |
|
Thank you for your reply @MarcusKay That is a good remark. Perhaps I should have stressed SwiftUI less so in my question. I would like to use SwiftUI for the UI design, but the data synchronisation doesn't live there indeed. Let me then rephrase my question more in general. How can I implement simple data sharing between users in Swift? Then, does anyone have some pointers on how to integrate that data layer with SwiftUI? For example, CloudKit allows you to store data in The CoreData CloudKit intergration seems the best shot right now, and the only thing I can find in tutorials. However, it does not allow for data sharing (NSPersistentCloudKitContainer does not support a shared scope) and Apple engineers recommend implementing the sharing through Alternatively, if there are experienced Swift programmers here that would state 'This topic is advanced and not yet well documented, provided or implemented in Swift(UI)' I would love to hear that as well. Possibly Apple does not provide much resources for this, and the current main approach is to rely on third-party database frameworks (Realm) instead? I do notice an almost absolute absence of tutorials on data sharing between users, especially in SwiftUI, while it is such a simple concept or requirement. Many thanks in advance! |
|
|
|
hi, glad to see this question resurface, since it's something i will be adding to an app (very soon, i hope). Isaiah wrote that
good news: things have changed! be sure to check out the WWDC21 video Build apps that share data through CloudKit and Core Data, since a new capability added to i think this will be my sharing solution going forward. hope that helps, DMG PS. here's where you can some related Apple sample code, although i am not sure this is directly on-point. if you follow the Apple Developer Forums, look for the tag "wwdc21-10015" |
|
|
|
Any success with sharing on |
|
I'm also looking for similar help, but I only want to sync data across devices logged into the same account, like my iPad and iPhone. |
SAVE 50% All our books and bundles are half price for Black Friday, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.