This will probably be a bit vague of a question, b...
# ios
This will probably be a bit vague of a question, but it’s related to ktor, and we’re generating an OpenAPI client from a certain source, into KMM code. Not sure if anyone has any sort of experience when it comes to KMM, OpenAPI and iOS. Let’s take this client for example, since I had troubles integrating this from the beginning (I found a workaround back then, but now there’s a major issue with our own client) These errors only occur on Kotlin Native, specifically for iOS. The issues are pretty similar to this: Our solution was to wrap it inside an immutable object, and yes, it worked.
Copy code
object ClientWrapper{
    val api = PetApi()
While it did work, now we have some adjustments on our own client. It needs to have a Bearer Token. In order to that, I need to call the
function inside the
. But I can’t do that when it’s wrapped in an immutable class. So I had to instantiate the Api object everytime I need to set the bearer token. The thing is, it’s not working at all in iOS. It gives me off an error of “Frozen Mutability Exception”, it’s kind of pointing out on the lazy variables. While I get the gist of the problem, what I’m not sure of is how to do some workarounds to solve this problem. Putting a
on the client wrapper itself doesn’t seem to work at all. Has anyone ever solved this? I’m seeing certain youtrack posts that it will not be solved until Kotlin changes some memory stuff, but I’m not sure. I hope someone can help me figure this out. Thank you.
We use moko-network for generating code for using with ktor and it wirks with iOS just fine
👍 2