Anyone have examples of a mpp framework that needs...
# multiplatform
b
Anyone have examples of a mpp framework that needs to dynamically link against another framework?
Trying to do this with various linker opts and having some difficulty
k
I don't have an example, but I have this working.
I can probably assist
b
Great! I’ve added
-framework <lib>
and
-F<path>
to the binary linker opts. Problem is that when I inspect the framework with otool -L, there’s no command added to dynamically link the framework. On top of that, I end up with all of the symbols from that framework in my main framework’s symbol table (causes lookup issues when launch the app)
k
Is this an objective C framework that you're consuming via cinterop?
b
It’s SQLite bundled into a framework. We use it In the main app, and I need it to link here as well
o
Is main app in Kotlin?
s
Is your Kotlin framework dynamic or static?
r
This may or may not help (group of 2 gists, don’t miss the link) https://gist.github.com/Ribesg/7a2b14841ad91d121bda24b6b1a7a054
b
The mpp framework is dynamic. Would like to dynamically link the SQLite framework
My current thought is that the linking happens for the klib, and then klib is packaged into a framework separately, which is why I don’t see the results of my ld flags using otool -l
k
you will need to link both frameworks into your app
either via pods or embedded binaries
s
there’s no command added to dynamically link the framework.
On top of that, I end up with all of the symbols from that framework in my main framework’s symbol table (causes lookup issues when launch the app)
Could you clarify? It’s not clear how both can happen at the same time. What do you mean by “lookup issues”?
b
The symbol table for the k/n framework ends up with all of the symbols from the SQLite framework in it (maybe expected). But then because there’s no command added (I.e. otool -l doesn’t show any reference to SQLite), when something in the main app goes to reference a SQLite symbol, it sees it in the K/N framework’s symbol table and errors with a read failure (that symbol isn’t used by the framework, and the framework has no command to load the SQLite framework)
sees it in the K/N framework’s symbol table and errors with a read failure (that symbol isn’t used by the framework, and the framework has no command to load the SQLite framework)
This part is a bit speculative, but the error trace strongly suggests this is what’s happening (read error is accurate)
k
what is the actual error?
b
With this, it links fine (sqlite framework is built at $buildDir/sqlite3.framework). At runtime, it crashes when some other code goes to access a sqlite symbol (specifically a call to
sqlite3_collation_needed
) that the MPP framework does not use (read failure at 0x0)
Copy code
binaries {
    framework {
        embedBitcode = 'DISABLE'
        linkerOpts = ["-framework sqlite3", "-F$buildDir"]
    }
}
k
and you have embedded this framework in your app bundle?
b
yep
k
i've not seen anything like that before
b
ended up fixing all of my issues by just linking a local dylib (which properly adds the dylib load command to the framework) and then using install_name_tool to update it to a relative path that uses
@executable_path
👍 1