https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
k

Kris Wong

02/10/2020, 9:13 PM
hmmm, looks like getting sqldelight w/ encryption is going to be a challenge for K/N. anyone tried this?
b

basher

02/10/2020, 9:13 PM
you mean linking a custom sqlite?
k

Kris Wong

02/10/2020, 9:13 PM
sqlcipher, specifically
b

basher

02/10/2020, 9:14 PM
a compile-time option?
well in any case, if you need to link a custom sqlite, i know how to do that
k

Kris Wong

02/10/2020, 9:15 PM
are you suggesting that's the solution?
i'm not sure what other changes will be required on the native side. i haven't looked into it yet.
b

basher

02/10/2020, 9:17 PM
oh sqlcipher is a replacement
k

Kris Wong

02/10/2020, 9:17 PM
in theory the APIs are identical so it could be a drop in replacement
b

basher

02/10/2020, 9:17 PM
yeah so linking custom sqlite it what you want
in your sqldelight block in build.gradle, add
linkSqlite = false
then you'll have to update linker flags to link sqlcipher
getting the linker flags right is the hard part
and it varies based on how you distribute on the iOS side
k

Kris Wong

02/10/2020, 9:22 PM
oh, it's static. i'd need to link library into the iOS app anyway. which means it may even be possible to just use sqlcipher instead.
i'd think the exported symbols would match up. i guess i'll find out.
👍 1
gah. they don't match perfectly because you have to specify the key to the open function
b

basher

02/10/2020, 9:32 PM
Could you build the library with an extra open function that calls the sqlcipher one passing the key hard-coded?
k

kpgalligan

02/10/2020, 9:37 PM
It’s doable. Just need to sort out the details and write it up. I actually did this with j2objc and our custom driver
👍 1
Also looks like at least one person uses it: https://github.com/touchlab/SQLiter/pull/16
k

Kris Wong

02/10/2020, 10:08 PM
i think the original sqldelight can be forked in a minimal touch way that makes it easy to pull in upstream changes
b

basher

02/10/2020, 10:08 PM
Sqldecipher
k

Kris Wong

02/10/2020, 10:11 PM
lolz
k

kpgalligan

02/10/2020, 10:16 PM
Do you need a work of sqldelight, though?
b

basher

02/10/2020, 10:17 PM
You shouldn't if you can stub in that open function
k

Kris Wong

02/10/2020, 10:30 PM
well, I see it's actually using SQLiter for the native implementation, so still digging there
75 Views