Hi all, Anyone has any experience integrating a KM...
# multiplatform
t
Hi all, Anyone has any experience integrating a KMM in a Development Pod in iOS instead of the project itself? I was able to import the KMM in the development pod by adding it through podspec file but hitting a roadblock when I call those functions.
l
Hi, what is the roadblock you're hitting?
t
I have an app which uses that Development pod. When I run the app which further calls the function in the development pod (which has the KMM function), the app just crashes.
Right now, I am adding the KMM to the library like this: 1. Project file: Add the path the podspec file generated by KMM gradle 2. run pod install 3. It added the KMM module as a cocoapod int he development pod folder 4. Then I referred to that development pod in the podspec file of my ios library (development pod) this way:
Copy code
s.dependency 'accesstokenmodule'
l
What's the crash cause exactly?
The logs should show why the crash happens.
t
There is no error. It just goes to memory management with this
Kotlin_ObjCExport_toKotlinSelector
This is consistent with any function I tried calling which is in that Kotlin module.
There are no logs at all. thats why its so hard to track down a solution I guess.
l
I'd try to get another pod to work, starting from the Cocoapods Kotlin doc, or from an official sample, and once I get it working, I'd look at how the setup is different with what crashes
t
Just one thing though. When I try to call a function in the app instead of a development pod from this same KMM. the app works and there is no crash
My first assumtpion was maybe KMM only supports integration with an ios app and not in the development Pod?
l
The first call to Kotlin code from the pod crashes, did I understand correctly?
t
yup, from the pod it crashes! But same thing from the app, it doesnt crash?
l
It's very possible it's not supported. I'd ask @akapanina to be sure.
t
hmm okay. Thank you so much for looking into it and guiding me ahead 🙂 I really appreciate it.
Just an update, We were able to resolve the issue. It looks like the integration with the development pod is possible. The only thing to take care of is that the KMM is available by the time we try to instantiate it. As an example, if my KMM has a
class Foo
with a function
getFooString()
. I need to make sure that by the time I instantiate the Foo class as `private let foo = Foo()`the KMM module should be loaded. More like a race condition. In order to solve it, we added
private lazy var
instead of using
private let
when instantiating the class the very first time. So we wait till we need to use it in the hope that it will be available by then.
🔥 2
l
Great that you found the solution! What do you call the "KMM" exactly?
t
Kotlin Multiplatform Module
l
FYI, KMM stands for Kotlin Multiplatform Mobile, hence my request for clarification 🙂
t
ahh okay! Thank you 🙂