https://kotlinlang.org logo
Title
a

Andrew O Hart

11/29/2021, 2:26 PM
I know there is an example of sqlcipher in the kampkitsqlcipher github, but I can't find any examples of working with sqlcipher for ios there. Anybody experience with making calls sqlite3_open in multiplatform?
k

kpgalligan

11/30/2021, 2:00 PM
We generally use sqldelight to make db calls, but use sqlcipher rather than link with
-lsqlite3
on iOS. Sqliter (https://github.com/touchlab/SQLiter) manages the low level sqlite calls, and will work linked to either sqlite or sqlcipher. So, short answer, we have experience with it. Any particular questions?
a

Andrew O Hart

11/30/2021, 3:27 PM
Ah I see. We are using sqldelight on multiplatform already and right now we are implementing sqlcipher so we can handle migration of the db
Which has proven tricky since we didn't want to use cocoapods due to the overhead so it was hard figuring out how to actually build sqlcipher for it and integrate using cinterop, but that seems to be working now
Main issue I'm finding is I am unfamiliar with C and Objective C and how the Pointers work with Kotlin, so trying to open the db was very confusing
But I think i have that part working so I'm just working on the migration process now. My question was how to actually us the sqlite3_open call. but I think I have that working now
k

kpgalligan

11/30/2021, 6:32 PM
Hmm. Migrating sounds maybe tricky. Also apparently my notifications are off as I didn't see this. Anyway, if you find anything interesting let me know. I'm doing a general rethink on sql stuff as I'm going to be digging around the sqldelight driver with an eye towards the new memory model, so might be a good time for anything else interesting.
a

Andrew O Hart

12/01/2021, 1:36 PM
Yeah, the logic for Android is done so I have something to follow, but the tricky part is translating that to ios, the pointers etc make it a bit tricky and trying to work with the file system. It's also a lot of hassle having to debug it since I need to build it without sqlcipher, then build again with sqlcipher. also need to change settings in the build.gradle because right now its being build differently to our current implementation for ios so its tricky for sure
@kpgalligan I managed to migrate the old data to new data on ios, but running into an issue here: https://kotlinlang.slack.com/archives/C3PQML5NU/p1638546801046100 Not sure if any use, hoping to write a little article on the process of building SQLCipher as a static library and importing into kotlin and then doing the migration process