Hi there! Anyone ever compiled an iOS framework th...
# multiplatform
d
Hi there! Anyone ever compiled an iOS framework that includes SQLCipher via cocoapods, and ever been able to use sqlcipher functions such as
sqlcipher_export
at runtime? I’m constantly getting this error when running the iOS app that includes the kmp framework:
Copy code
no such function: sqlcipher_export in "SELECT sqlcipher_export('plaintext');"
any ideas? thanks!
@kpgalligan kindly asking to you, hope it wouldn’t be a bother. I saw this discussion where you’ve been super helpful 🙏
k
The link in that post seems wrong. IT was an earlier version in the history that had the export: https://github.com/touchlab-lab/KaMPKit-encrypted/blob/2f9b486dbae101f761d4f955aa1[…]7a638c/shared/src/iosMain/kotlin/co/touchlab/kampkit/KoinIOS.kt It did work. I would guess somehow the platform sqlite is getting linked rather than SQLCipher.
Would need to see the build gradle config, then I’d check in your Xcode build settings and confirm
-lsqlite3
is not in the “Other Linker Flags”
d
In my build gradle I have the following
Copy code
sqldelight {
    database("<redacted>") {
        packageName = "<redacted>"
        linkSqlite = false
    }
}
and in the Xcode project there isn’t
-lsqlite3
in “Other Linker Flags”. Since the project is using Carthage to import KMP modules, I’m replacing directly the .framework file to test the KMP module. We’re not including it using cocoapods, but we are using cocoapods to add sqlcipher into the multiplatform project to avoid all the cinterop configuration
k
How are you adding the SQLCipher binary? Carthage? The cocoapods config would only run cinterop.
d
I'm including the sqlcipher dependency only in the kmp module using cocoapods. Should I include it also in the iOS project itself or can it be inherited from the kmp framework?
k
Well, I pretty much avoid Carthage for KMP, so I can’t tell you a whole lot about how all this would work. Cocoapods KMP dependencies generally just tell cinterop what to generate. You need to add SQLCipher to your Xcode project as well. If you use Cocoapods to build everything, the KMP-generated podspec would tell Cocoapods to also include the SQLCipher Cocoapods binary and link it. Since you’re using Carthage, you need to add SQLCipher with Carthage and drag that in as well. Now, since you’re getting an error for
sqlcipher_export
, but the sqlite calls otherwise run, that suggests the sqlite library is still being linked somehow even though you don’t see it in the other linker args, which you’ll (probably) need to resolve to make sure when you add SQLCipher that the SQLCipher binary and the built-in sqlite library don’t conflict.
d
Thanks a lot. I’ll try to add sqlcipher as a dependency directly to the Xcode project. Was also one of my guessing but at the end I never tried it.
that suggests the sqlite library is still being linked somehow even though you don’t see it in the other linker args,
can it be due to the usage of SQLDelight in other kmp modules without the linkSqlite flag specified? such modules are added to the xcode project with Carthage as well
k
Certainly possible. Really hard to debug these kinds of things over slack :)
d
Definitely 🙂 thanks for the support, I’ll be back with some updates just to share knowledge
Done! Sqlcipher added in the iOS project and now the sqlcipher_export function is available at runtime! I’m only facing a generic SQLITE_ERROR when running
DETACH DATABASE encryptedDb
, did you encounter something similar?
148 Views