Hello there! I successfully moved from swift code...
# kmp-swift-package-manager
r
Hello there! I successfully moved from swift code to kotlin my custom implementation of google maps ios. This is a must feature thanks for doing that 🥳 and nice to see you here @François 😊 I have tried your library and I thought this was a must to have natively in KMP, it helps a lot since pods suck 😅. My next step is trying to move that google maps implementation to a gradle submodule and try to compile it too 🤙🏻. Also I would like to try with other less popular iOS libraries. One question, in the native version is it currently possible for libraries that are written exclusively in Swift, to import them someway or use them some way in a gradle module using Kotlin or in Swift with the new system? Or did we need to wait for KMP full swift compatibility? Thanks in advance, and thanks for all your contributions!
t
Hey
is it currently possible for libraries that are written exclusively in Swift
Pure Swift is not supported, but Swift annotated with @objc/@objcMembers is supported. What you can try is to create a local package using
Copy code
swift package init --type library
, then you import your pure Swift dependency in this package, and manually expose the parts that are necessary for your integration
r
@Timofey Solonin Ok, Understood. I'll try that, maybe a guide for that use case will be appreciated.
f
spmforkmp has a builtin bridge, but it’s possible to use a local package like @Timofey Solonin recommend, and migrate to the new package manager when ready
r
@François Yes, I tried that way the problem was that I couldn't see if my implementation was correct until I compile. So I suppose that if I create a local library I could see what I'm doing in swift and expose it the same way with @objc/@objc members
f
Yes, that’s a better approach
❤️ 1
FYI, the Swift import to Kotlin through
@objc/@objc members
has some limitations that swift doesn’t have when it accesses content with @objc.
I really need to write a guide about it...
t
guide for that use case will be appreciated
We will do a guide specifically for this use case in KT-85039 soon. Unfortunately, we don't have any public samples, but this test illustrates what you want to do roughly
💯 1
f
@Timofey Solonin there are a lot of scenarios to know when import swift code thought @objc, like nullability issue, incompatible type, suspend/async, error catching...
Swift do better when importing @objc code than kotlin
t
I agree that importing Swift APIs this way is far from perfect, but it can satisfy a use case. If you write a guide referencing some common pitfalls, that would also be great!
f
I’m thinking about it 🙂
@Roger Roca (rogydev) I have made a small guide for the local package https://spmforkmp.eu/usages/largebridge/ long time ago
❤️ 1
n
I'm currently trying to create a KMP library to access native store methods. For iOS, StoreKit 2 is Swift only, so I'm going to try to wrap SK2 methods using a local Swift Library. Thank you @François for your playground, it's gonna be useful 👍
❤️ 1