You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use sqldelight in a KMM app project. I store sensitive cached data, mostly in the form of base64 encoded images as strings.
It's only meant to be used as a cache when there is no network.
I want to avoid the underlying SQLite db from being included in an iOS backup or iCloud sync/backup.
I ended up setting the attribute right after the NativeSqliteDriver is created by using this function:
@OptIn(ExperimentalForeignApi::class)
fun setExcludeFromBackup(){returnmemScoped{
val databasePath =DatabaseFileContext.databasePath(databaseName, null)if(NSFileManager.defaultManager.fileExistsAtPath(databasePath)){
val errorRef =alloc<ObjCObjectVar<NSError?>>()Napier.i{"Excluding ${databasePath} from iCloud/Backup!"}
val success =NSURL.fileURLWithPath(databasePath).setResourceValue(NSNumber(bool =true), NSURLIsExcludedFromBackupKey, errorRef.ptr)if(!success){Napier.i{"Excluding ${databasePath} from iCloud/Backup failed! Reason: ${errorRef.value}"}}}}}
I have yet to test if this does work at all by really doing a backup of a real iphone and check if the database file is not included. So be aware this is untested.
Activity
dusiema commentedon Sep 11, 2023
I ended up setting the attribute right after the NativeSqliteDriver is created by using this function:
I have yet to test if this does work at all by really doing a backup of a real iphone and check if the database file is not included. So be aware this is untested.
dusiema commentedon Sep 11, 2023
Side note: I pulled a backup from an iPhone but seemingly developer signed apps are not included in an iPhone backup anyways.