https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
d

diesieben07

04/15/2018, 9:07 PM
I had a lot of trouble getting that to work, mostly because of
actual typealias
not working correctly yet. That makes it impossible to use e.g.
UUID
in your domain objects.
l

lex

04/16/2018, 5:44 AM
@diesieben07 try this and post your feedback please common:
Copy code
package your.domain.package

expect class UUID

expect fun randomUUID() : UUID
jvm:
Copy code
package your.domain.package

actual typealias UUID = java.util.UUID

actual fun randomUUID () : UUID = java.util.UUID.randomUUID()
js:
Copy code
package your.domain.package

import ext.js.npm.uuidv4

actual class UUID

actual fun randomUUID() : UUID = uuidv4()
Copy code
@file:JsModule("uuid")
package ext.js.npm

@JsName("v4")
external fun uuidv4() : dynamic
package.json
Copy code
"dependencies": {
    "uuid": "^3.2.1",
...
  }
d

diesieben07

04/16/2018, 9:25 AM
It's broken in the IDE, various things will be marked as errors even though they aren't. It's already reported on Youtrack.
l

lex

04/16/2018, 11:14 AM
it is work in my case, what structure of your project?
what version of IDEA and kotlin you use? do you build with gradle?
d

diesieben07

04/16/2018, 11:53 AM
Your case works, but as soon as you try to do anything more elaborate (e.g. have a method in common that takes a
UUID
and call that method from the JVM module) you get all kinds of errors. Using 2018.1.1 and Kotlin 1.2.31. I build with gradle. Like I said, this bug is already reported and acknowledged: https://youtrack.jetbrains.com/issue/KT-22868
l

lex

04/17/2018, 7:31 AM
it is just IDEA problem, gradle builds it successfully
d

diesieben07

04/17/2018, 2:50 PM
I know. I said that above 😉
l

lex

04/18/2018, 3:34 AM
oh, you are right 🙂
5 Views