Aman Shaikh
08/15/2025, 12:05 AMexpect/actual.
For example, I want my common code to have something like:
expect class GoogleAuthProvider constructor(context: Any) {
suspend fun signIn(): GoogleAccount?
suspend fun signOut()
}
If I were using CocoaPods, I could do something like this in `iosMain/GoogleAuthProvider.ios.kt`:
import cocoapods.GoogleSignIn.GIDSignIn
import com.peliplat.mobile.data.model.auth.socialAuth.GoogleAccount
GIDSignIn.sharedInstance.signInWithPresentingViewController(rootViewController)
That works because CocoaPods dependencies are automatically available to Kotlin via the cocoapods.* import.
But in the case of SPM, I’m not sure:
• How can I import the SPM dependency (Google Sign-In) so that I can call its APIs in iosMain Kotlin code?
• Do I need to create a Swift wrapper for SPM dependencies and then expose them to Kotlin?
• What is the recommended way to implement the actual class in KMP when using SPM instead of CocoaPods?
I’m new to KMP, so any guidance or examples would be super helpful 🙏
Cc: @OrlandoPablichjenkov
08/15/2025, 12:50 AMAman Shaikh
08/15/2025, 7:20 PMDumitru Preguza
08/18/2025, 1:23 PMAman Shaikh
08/25/2025, 4:49 PMPablichjenkov
08/25/2025, 10:12 PMAman Shaikh
08/26/2025, 12:39 AMPablichjenkov
08/26/2025, 1:18 AMSwiftLibDependencyFactory classPablichjenkov
08/26/2025, 1:21 AMPablichjenkov
08/26/2025, 1:27 AMSwiftLibDependencyFactory as a Singleton in swift side(the use of shared). But you can also create one single instance manually in the ApplicationDelegate and pass a swift injection framework root container, in case you are using dependency injection in Swift. Then having the root DI container from swift side, you can use it to resolve all the dependencies inside SwiftLibDependencyFactoryPablichjenkov
08/26/2025, 1:28 AMPablichjenkov
08/26/2025, 1:38 AM