Issue with Okta iOS in Kotlin Multiplatform Project

I’m working on a Kotlin Multiplatform project and need to integrate Okta for authentication. I’ve successfully implemented the functionality for Android using file.android.kt, but I’m encountering issues with the iOS part.

The problem is that I need to either import the Okta iOS library into a file.ios.kt file to run platform-specific functions, or somehow call Okta functions defined in Swift from this Kotlin file. However, Kotlin Multiplatform doesn’t allow directly importing Swift or Objective-C libraries into a .ios.kt file.

The solutions I’ve considered so far are:

  1. Import the Okta iOS library directly into file.ios.kt.
  2. Create a Swift class that handles the Okta functionality and call its methods from file.ios.kt.

Currently, I’m leaning towards the second approach: creating a Swift class that uses Okta and exposing its functions to Kotlin using interoperability. However, I’m wondering if there’s a more efficient way or if anyone has successfully imported the Okta SDK directly into a .ios.kt file.

Any advice or solutions would be greatly appreciated. Thanks!

Okta supports okta-react-native for mobile Multiplatform.
If this doesn’t fall in line with your project, you might want to check if there is an existing OAuth compliant library created for Multiplatform already.

I have not used it but this lib might be helpful:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.