<@UNKMT11L3> quick question, when using Kotlin 2.3...
# swift-export
g
@Artem Olkov quick question, when using Kotlin 2.3.0-RC (and up), should we except swift primitive types - even if we run
embedAndSignAppleFrameworkForXcode
?
a
that depends 🙂 what kotlin code do you have in mind?
g
I ask because I’m seeing this:
Copy code
open class KotlinLong : KotlinNumber {

    public init(value: Int64)

    public convenience init(longLong value: Int64)
}

open class KotlinBoolean : KotlinNumber {

  public init(value: Bool)

  public convenience init(bool value: Bool)
}

public class GradientScreenUIViewController : KotlinBase {

  public convenience init()

  open class var shared: GradientScreenUIViewController { get }

  open func make(randomize: @escaping (KotlinLong) -> Void) -> UIViewController

  open func update(state: ScreenState)
}

public class TestScreenUIViewController : KotlinBase {

  public convenience init()

  open class var shared: TestScreenUIViewController { get }

  open func make(value: Bool) -> UIViewController
}
GradientScreenUIViewController
uses
KotlinLong
but
TestScreenUIViewController
uses
Bool
I was expecting it to be
KotlinBoolean
My generated code:
Copy code
public struct TestScreenRepresentable: UIViewControllerRepresentable {
    let value: KotlinBoolean

    public func makeUIViewController(context: Context) -> UIViewController {
        TestScreenUIViewController().make(value: value)
    }

    public func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
        //unused
    }
}
will fail because the exported framework asks for Bool instead of KotlinBoolean in
.make(value: value)
a
With Objective-C export it's OK to see
Kotlin*
. It is used each time the type should(may) be boxed. In your example it was used because it is a parameter inside an escaping closure (btw, probably may be used w/o boxing, probably can be reported as a bug) I would say that this doc (and neighbouring articles) covers this quite well.
g
Correct, in that .md you can see that the expected type for Boolean should be
Boolean?
->
KotlinBoolean?
a
Yes, and for non optional type - Bool is expected 🙂
and this (for swift export
But your project doesn't use swift export?
g
this specific one is not exporting with swift export, is using
embedAndSignAppleFrameworkForXcode
. And if I use it inside a closure:
Copy code
public class TestScreenUIViewController : KotlinBase {

  public convenience init()

  open class var shared: TestScreenUIViewController { get }

  open func make(value: Bool, otherValue: @escaping (KotlinBoolean) -> Void) -> UIViewController
}
the type is expected.
a
Oh, 2 question 1. do you see this behaviour on compile time, or inside AS? 2. Was it working the other way around before 2.3?
g
actually i cannot see the result framework in AS, I don’t know if it is a bug, with Xcode I can see it.
it’s compile time, when I build the project and go inside the import to see the resulting framework
👌 1
I think it was working as I expected, I don’t know when started failing.
perhaps 2.3.0-RC?
I’ll investigate 😉
a
I’ll investigate
Thanks! If it was working on 2.2.21 as you expect - please file a ticket for that, as is it definitely a problem
👍 1
g
Tested with 2.2.21 and 2.2.20 and the result is:
Copy code
public class SampleData : KotlinBase {

  public init(v1: Bool)

  open func doCopy(v1: Bool) -> SampleData

  open func isEqual(_ other: Any?) -> Bool

  open func hash() -> UInt

  open func description() -> String

  open var v1: Bool { get }
}

public class MainKt : KotlinBase {

    open class func ExportTestFun(v1: Bool, v2: @escaping (KotlinBoolean) -> Void, v3: SampleData)

    open class func MainViewController() -> UIViewController
}
For the input:
Copy code
data class SampleData(val v1: Boolean)

fun ExportTestFun(v1: Boolean, v2: (Boolean) -> Unit, v3: SampleData){
}
so I’ll have to take this into account in my KSP 😅
K 1
Yup, my fault — some corner cases weren’t considered due to my lack of knowledge. Sorry for the false positive 😅
👌 1