Hi everyone 👋
I’m trying to figure out how to use
Swift Package Manager (SPM) to import the Google Sign-In SDK and make it available in Kotlin Multiplatform (KMP) common code via
expect/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:
@Orlando