How to enable iCloud support for sqlite?

I want to provide iCloud support for my shell around sqlite. Not used coredata.

I wonder how to enable iCloud for it. The contents of the database are constantly changing (for billing). Also, if it is possible to have some kind of version control, it will be fine.

Are there any examples that I can use for this?

+6
sqlite3 icloud
source share
2 answers

The short answer is no, you will need to use Core Data, as you suspected. Apple has stated that sqlite is not supported.

Edit: Check out the iCloud section now in the iOS Application Programming Guide under Using iCloud with a Database

Using iCloud with a SQLite database is only possible if your application uses Master Data to manage this database. Accessing real-time files in iCloud using SQLite interfaces is not supported and is likely to corrupt your database. However, you can create SQLite-based master data storage if you follow a few additional steps when setting up Basic data structures. You can also use other types of Core Data Warehousing, that is, non-SQLite-based storage, without any special modifications.

+6
source share

You cannot just put the SQLite database in an iCloud container because it can be damaged. (As SQLite DB changes, temporary files are created and renamed, so if the synchronization process starts to copy these files, you will get a damaged database.)

If you do not want to switch to Core Data, you can do what Core Data does: store your database in the folder of your document and store the transaction log in the iCould container. Each time you change the database, you add these changes to the log file so that you can play them back and make equivalent changes on other devices.

This becomes quite complicated: in addition to the correct log logic and response, you will want to combine redundant changes and periodically collapse the log into a full copy of the database.

You may have an easier time developing a solution if you can use the knowledge of your application (basic data should solve the problem in the general case). For example, you can save invoices as separate files in a cloud container (text, property list, XML, JSON, etc.), recording them as database changes and importing them only if the system reports that they have been created or modified.

In general, your choice is to either switch to Core Data or write your own synchronization solution. Which one best depends on the features of your application.

+7
source share

All Articles