0

I'm currently building an API library with Kotlin Multiplatform, which I want to share between Android & iOS projects.

API responses, in some cases, contain optionals (which is a great feature of both Kotlin & Swift). For example:

data class User(val name: String, val email: String?)

When building the library for Android (JVM) the optionals are there to works with, when using the iOS Framework inside an iOS project, they are gone because the Framework is exported as an Objective-C framework.

Does anyone know how to either create a Swift framework (is this even possible), or keep the optionals with some sort of workaround? Thanks!

Daan
  • 475
  • 5
  • 17
  • 1
    Hi! Are you talking about nullability here? If so, everything should work fine. `_Nullable` annotations are being emitted and therefore Objective-C framework doesn't lose this info. – Artyom Degtyarev Mar 12 '20 at 14:21
  • @ArtyomDegtyarev you are absolutely right, totally overlooked this for some reason. Thanks! – Daan Mar 12 '20 at 15:24

1 Answers1

1

The answer (thanks to @Artyom Degtyarev); this is already the case. Optionals are kept in the Objective-C framework.

Daan
  • 475
  • 5
  • 17