Hi everyone, I’m working on a Kotlin Multiplatform...
# multiplatform
v
Hi everyone, I’m working on a Kotlin Multiplatform (KMM) project with Compose Multiplatform (CMP). I’ve integrated Stripe payments on Android successfully, and now I’m trying to integrate Stripe on iOS.
I’ve created a StripeController class in Swift and marked it with @objc so it can be used from Kotlin/Native. Here's the Swift class:
Copy code
@objc class StripeController: NSObject {
    // Stripe setup and present logic...
}
In my Kotlin iOS code (iosMain), I'm trying to import and use this Swift class like this:
Copy code
import iosApp.StripeController
private val stripeController = StripeController()
However, I’m getting an "Unresolved reference: StripeController" error when trying to import or use it.
The StripeController is inside the iosApp module, and I’ve already: Marked the Swift class and its methods with @objc Ensured the class inherits from NSObject
Is there something I might be missing in order to make the Swift class visible to Kotlin/Native? Any help would be appreciated — thanks!
d
From my understanding your shared module does not depend on the iosApp module, it's the other way around, so it's unable to see the StripeController code. There are a couple of ways you could achieve this communication, but the most common way you find when looking into tutorials would be to declare an interface in your shared modules iOSMain code and have it be implemented in Swift in the iOSApp and inject it via DI (or some global variable) so that it can be used in shared.
☝️ 1
☝🏻 1
☝🏿 1
c
v
Hey daniel, do you have any examples?