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

Berkan

04/27/2021, 8:25 PM
Are all cocoapods dependencies supposed to work in KMP? For example AFNetworking works and its .knm file is generated. But when I add some other random dependency, its .knm file is completely empty
l

louiscad

04/27/2021, 9:20 PM
Hello! Please, provide at least one example of "other random dependency" where it doesn't work the way you expect.
b

Berkan

04/28/2021, 8:00 AM
@louiscad For example
SnapKit
works, and I can use its functions. But
pod("VecoreSDK", moduleName = "VecoreSDKFramework")
does not work correctly, since I can't use the library
1_SnapKit.knm
has cinterop code and
0_VecoreSDKFramework.knm
is empty
l

louiscad

04/28/2021, 8:01 AM
Isn't it a Swift-only library that is not exported to Objective-C, and therefore, not visible to Kotlin/Native?
b

Berkan

04/28/2021, 8:02 AM
How can I find out its its swift-only?
And if it is, is there no fix for it?
l

louiscad

04/28/2021, 8:04 AM
@Berkan If it's 100% Swift and there's no
@objc
annotation, it's not Obj-C compatible. One solution is to fork the library to add that interop capability.
b

Berkan

04/28/2021, 8:19 AM
This library doesn't seem te be opensource, can I maybe make some kind of wrapper file with obj-c that calls the swift functions?
l

louiscad

04/28/2021, 8:20 AM
Yep, you can try a Swift wrapper that is exported to Obj-C.
b

Berkan

04/28/2021, 8:22 AM
Do you know if theres any guide for this? I have limited knowledge of iOS, I'm mainly android/kotlin developer.
l

louiscad

04/28/2021, 8:23 AM
You can definitely Google how to make a Swift library, and then, it's as simple as adding the
@objc
annotations, and publishing your library (which is simpler than publishing Android/Kotlin libraries at the moment, GitHub is all you need).
b

Berkan

04/28/2021, 8:37 AM
Wouldn't I have to create an obj-c framework in this case? instead of a swift library
l

louiscad

04/28/2021, 8:37 AM
It's kinda both
b

Berkan

04/28/2021, 8:49 AM
Thank you for your help so far. Do you perhaps know of some example of this?
l

louiscad

04/28/2021, 8:50 AM
I'd Google it, but that's something you can as well 😉
b

Berkan

04/28/2021, 8:56 AM
I actually was able to download the .framework file of this library. Does this open up some other possibilities to make it work?
l

louiscad

04/28/2021, 8:57 AM
You don't need that. You just need to declare the dependency on it in your Swift library
b

Berkan

04/28/2021, 8:58 AM
Ah, through pods or manually?
Just to be sure, would I have to create a swift package, framework or static library?
l

louiscad

04/28/2021, 9:23 AM
Framework that you publish with Cocoapods
👍 1
b

Berkan

04/28/2021, 10:18 AM
I think I figured out how to make this framework. Do you know if its possible to upload this framework as a private pod and still use it in Kotlin in build.gradle.kts?
l

louiscad

04/28/2021, 11:31 AM
I'm 99% certain it's possible. I think a private git repo will work so long as you have ssh configured on your machine to access it.
b

Berkan

04/28/2021, 1:55 PM
Hi @louiscad. Do you happen to know if I can just use this wrapper framework i created as-is? So not calling it through a pod() dependency in build.gradle
l

louiscad

04/28/2021, 2:42 PM
@Berkan I don't think so, though that may change at some point. That said, you should be able to use a local pod, that can be located into your git project.
b

Berkan

04/28/2021, 2:43 PM
How can I point KMP to look for the pod spec in my git repo?
l

louiscad

04/28/2021, 2:45 PM
I don't know from the top of my head, but I'm pretty sure you'll find the info in the Kotlin docs, Cocoapods docs or by simply searching on Google with the right keywords.