rocketraman
10/02/2024, 1:40 PMUndefined symbols for architecture arm64:
"_sqlite3_bind_blob", referenced from:
_kfun:co.touchlab.sqliter.interop.ActualSqliteStatement#bindBlob(<http://kotlin.Int;kotlin.ByteArray|kotlin.Int;kotlin.ByteArray>){} in MobileSdk[arm64][2](MobileSdk.framework.o)
"_sqlite3_bind_double", referenced from:
_kfun:co.touchlab.sqliter.interop.ActualSqliteStatement#bindDouble(<http://kotlin.Int;kotlin.Double|kotlin.Int;kotlin.Double>){} in MobileSdk[arm64][2](MobileSdk.framework.o)
However, my cocoapods plugin framework isStatic = true
so why would these symbols not be found?rocketraman
10/02/2024, 1:51 PMkpgalligan
10/02/2024, 1:52 PMkpgalligan
10/02/2024, 1:54 PM-lsqlite3
to linker flags. Even the JB docs are "wrong". Yes, making the framework dynamic works around the problem, but linker flags are normal native dev things. There are plenty of valid reasons you won't want a dynamic framework. But, yeah, if you don't want to bother with linker flags, for that specific issue, you can use a dynamic framework.kpgalligan
10/02/2024, 1:55 PMrocketraman
10/02/2024, 1:57 PMlinkSqlite
is supposed to do (it defaults to true
)kpgalligan
10/02/2024, 2:18 PM1) For cocoapods lint, where would I add this linker flag?No idea. Quick google has something that sounds promising, but we've been off CocoaPods for a while and I've only done linker flags for builds: https://stackoverflow.com/questions/59299875/how-do-i-solve-linker-errors-from-the-cocoapods-lint-command
2) Isn't this what the SQLDelight configurationSqlDelight config does that to try to make life easier for Android devs, but I'm on the fence about it. It's sort of "magic", but leads to all kinds of confusion. For example, think of "static Framework" like "jar" and "dynamic Framework" like "aar". Not a direct comparison, but the dynamic framework carries some more metadata. That linker flag is one example. That's why you don't need it elsewhere. However, dynamic frameworks in other linking contexts can be a (relative) nightmare: https://crashkios.touchlab.co/docs/bugsnag#step-3---setup-dynamic-linking-optionalis supposed to do (it defaults tolinkSqlite
)true
kpgalligan
10/02/2024, 2:18 PMrocketraman
10/02/2024, 2:28 PMlinkSqlite
I think I understand: it sets the metadata for dynamic linking, but the confusion arises because it does not add the link flag to xcode for static linking. Is that right?
The SQLDelight docs on that flag could really use some love in that case.rocketraman
10/02/2024, 2:32 PMwe've been off CocoaPods for a whileUnfortunately I'm stuck on CocoaPods because this library is used in a React Native project, and they haven't migrated to SPM yet.
rocketraman
10/02/2024, 2:42 PMsqlite3
to cocoapods via extraSpecAttributes["libraries"]
which seems to match the cocoapod docs:
extraSpecAttributes["libraries"] = "'c++', 'sqlite3'"
That would probably do it for the cocoapods lint with a static framework (but I'm fine with dynamic linking for now).kpgalligan
10/02/2024, 2:56 PMReTL;DR - Yes. The longer version is that a dynamic framework is sort of a standalone executable living inside your executable (iOS experts, I said "sort of"). It needs everything defined to conceivably be run, or at least used. Static is more of a box of executable code. the final build takes chunks of that code and directly inserts it into your final executable. So, when building a static framework, the compiler doesn't care if code you reference is actually available, just that you've defined it. For ObjC, you just need headers to other code, and supplying that binary at link time is your problem. For dynamic, while assembling, it expects that binary to be available. To ensure that, dynamic frameworks also include your defined linker flags. In this case,I think I understand: it sets the metadata for dynamic linking, but the confusion arises because it does not add the link flag to xcode for static linking. Is that right?linkSqlite
-lsqlite3
.
KMP is difficult for most devs, because most are Android devs, and all this "linking" stuff is pretty foreign, unless you've done a lot of JNI. The particulars of Xcode tooling are sort of weird too. So, a lot of the docs are "turn on linking in SqlDelight config, and use a dynamic framework". However, for anything beyond fairly basic KMP, you'll need to have a working understanding of this stuff, or struggle quite a bit. That's why I push back on saying "use dynamic" without at least a mention that that is an oversimplified "solution".rocketraman
10/02/2024, 2:58 PMkpgalligan
10/02/2024, 2:59 PMThat would probably do it for the cocoapods lint with a static framework (but I'm fine with dynamic linking for now).KMMBridge used to be more "balanced" between CocoaPods and SPM, but at this point, almost everybody wants SPM, and the actual publishing of CocoaPods is much more complex, because of the external spec repo, so the new version of KMMBridge supports CocoaPods, but the recent tutorials don't go into it. I kind of prefer CocoaPods personally as I've done it for a long time, and SPM is very locked down, which makes KMP build integration brutal, but CocoaPods is "a lot", config wise, and brain is full. That snippet you sent sounds right.
kpgalligan
10/02/2024, 3:01 PMkpgalligan
10/02/2024, 3:02 PMkpgalligan
10/02/2024, 3:04 PMkpgalligan
10/02/2024, 3:05 PMrocketraman
10/02/2024, 3:06 PMkpgalligan
10/02/2024, 3:06 PM