3 ms·
We've been building iOS/macOS apps in local-first fashion for years. It works differently - there's a persistence library called Core Data on each client (most
by Void_ 3y ago
We've been building iOS/macOS apps in local-first fashion for years.
It works differently - there's a persistence library called Core Data on each client (most recently SwiftData). You can choose which database to use - most likely SQLite, but you could use XML files to store your data.
And then Core Data simply makes sure everything is in sync. It's an Apple system library, which means your data will automatically sync even if the app isn't running.
This feels like better approach than OP's Mycelite or better-known cr-sqlite.
Any reason why syncing on the database level would be better? It feels like something the library should do, not the database.
- anonzzzies 3y agoDoes something like that exist for other platforms? Web, Android, Linux?
- jamil7 3y agoTo be slightly pedantic and clarify. It's not actually anything to do with Core Data itself but CloudKit that is doing the syncing, more specifically, NSPersistentCloudKitContainer which came out a few years ago and makes adding CloudKit syncing to Core Data a one-liner basically. This year at WWDC we got CKSyncEngine which gives you the primitives to add a CloudKit syncing to your own persistence layer.
- Void_ 3y agoDoes that mean we could for example syncing Core Data with Firebase? That would allow to sync with a web app, exciting!
- ungamedplayer 3y agoSimply
- manmal 3y agoCoreData is a footgun when it comes to threading, my approach is to use a wrapper lib (eg CoreStore) that takes off the sharp edges, or just use SQLite directly (or with a lib like GRDB).
- gregoriol 3y agoCoreData doesn't work on any other platform, so you can only make Apple-apps. If you wanted to have a web version, an Android version or whatever else, you couldn't. So it's not a very good choice for most use-cases.
- jinjin2 3y agoWe use Realm for this. Very similar to Core Data, just removing some of the obvious footguns, but it works across both iOS and Android, and the real-time syncing is excellent.
- jamil7 3y agoI haven't used it in a long time but we had a lot of issues with random crashes showing up in logs and the compile-times are pretty bad. Has this gotten better since the Mongo acquisition?
- jitl 3y agoCoreData is fine for syncing a single user’s data between their devices. Something like cr-SQLite handles the more challenging case of syncing collaborative data between multiple users.