Hey guys, I am trying to use interface in swift, b...
# multiplatform
v
Hey guys, I am trying to use interface in swift, but it unable to find the property
commainMain
Copy code
interface ApplicationToken {
    val accessToken: String
    val refreshToken: String
}
iosMain
Platform.kt
Copy code
lateinit var tokenProvider: ApplicationToken
HttpClient.kt
Copy code
actual fun httpClient(config: HttpClientConfig<*>.() -> Unit) = HttpClient(Darwin) {
    config(this)
    engine {
        configureRequest {
            setAllowsCellularAccess(true)
        }
    }
    install(Auth) {
        bearer {
            loadTokens {
                BearerTokens(tokenProvider.accessToken, "")
            }
        }
    }
}
Now when I am to access
tokenProvider
in my swift code. It cannot find. I am adding image please have a look.
I tried another options to create class and implement my interface and call the class
Copy code
class getToken : ApplicationToken {
  let accessToken: String = ""
  let refreshToken: String = ""
}
_ = getToken() but it giving me error.
r
If
tokenProvider
is a top-level property in Platform.kt, then it will appear in Swift as
PlatformKt.tokenProvider
.
v
Thank you @russhwolf I'll try that