Ben Miller
Ben Miller

Reputation: 31

Sync SQLite database between two iPhones

I'm currently finishing up a project for IOS in Swift in which I've used an SQLite database to store data with SQLite.swift.

At the time of coding I didn't know that SQLite files are stored locally on the device/simulator and I need a way to run the app and have the database synced between two devices, as soon as possible. I tried swapping over to Firebase since I heard that would be a solution but I'm not at all familiar with it and am worried it might be risky given all my functions are written for SQL tables. I also thought of keeping the SQL and adding on a firebase database to fetch the data from but I'm not sure how to execute that.

The solution doesn't have to be 100% reliable for all cases- I just need to simulate running the app on more than one device with synchronised data.

Does anyone have any suggestion for a way to do this? Or a way to store the data on a computer so that it can be accessed by both devices?

Any advice is appreciated!

Upvotes: 3

Views: 1304

Answers (2)

pipacs
pipacs

Reputation: 1109

Let iOS do the synchronisation via iCloud, e.g. use Core Data with CloudKit: https://developer.apple.com/documentation/coredata/mirroring_a_core_data_store_with_cloudkit/setting_up_core_data_with_cloudkit?changes=_1

Upvotes: 0

DisQuad
DisQuad

Reputation: 63

There are no elegant solution with pure SQLite database. Just few offers:

  1. Moving to CoreData (You will get all what you want with sharing data between devices)
  2. Uploading database file to iCloud from one device and download it from another device
  3. Build up classic client-server communication

Upvotes: 3

Related Questions