Hey there I am using compose multiplatform and I a...
# multiplatform
m
Hey there I am using compose multiplatform and I am trying to implement Auth0 for Android & IOS so In common main I have `Auth0Service.kt`:
Copy code
expect class Auth0Service() {
    fun login(phoneNumber: String): StateFlow<LoginStatus>
    fun verify(phoneNumber: String, otp: String): StateFlow<VerifyStatus>
    fun logout(): StateFlow<LogoutStatus>
    fun userInfo(): StateFlow<GetUserInfoStatus>
    fun isAuthenticated(): StateFlow<IsAuthenticatedStatus>
}
I implement the actual for android
Auth0Service.android.kt
but I still need to implement it for IOS
Auth0Service.ios.kt
, in IOS I use
cocoapods
as a package manager and I install Auth0 and created a swift file for implementation but I need to expose it to iosMain to use the code in
Auth0Service.ios.kt
is there a way to compile the swift implementation and use it in kotlin? i tried to use swiftklib plugin and it keep syaing:
Copy code
error: no such module 'Auth0'
 7 | //
 8 | 
 9 | import Auth0
   |        `- error: no such module 'Auth0'
10 | import Foundation
d
For iOS we have the auth0 implementation in the iOS app an pass the interface/protocol back to shared where we init the shared library cause we couldn't think of a way to add auth0 to the shared project. This works for now since we hat only 1 app but will have to fix it since we are building the next app and plan to have a total of 6 apps running on the shared lib. So really interested in the solution you find
m
@dylan can you please explain more about your approach, What you mean about passing the interface/protocol back to shared?
d
In shared we defined an interface to call auth0 sdk functions and for Android implemented that in androidMain and added the sdk to the android dependencies. For iOS we implemented that interface in the iOS consumer app and pass an instantiated implementation of the interface back to shared so it can be added to the koin DI graph Since in shared we don't want to add cocoapods since the iOS team doesn't want to use that and only use spm
Kind of like the same way you would pass iOS views to compose multiplatform
m
@dylan Thank you so much it works
👍 1