Generate UUID on kotlin-multiplatform?

Veener picture Veener · Mar 29, 2019 · Viewed 12.2k times · Source

Are there any kotlin-multiplatform common functions to get a UUID/GUID?

 // ideally something like this
 val newUUID = UUID() // "1598044e-5259-11e9-8647-d663bd873d93"
 println("newUUID = $newUUID")

I'd prefer not to make separate Android and iOS versions using expect-actual.

Answer

Eugene Petrenko picture Eugene Petrenko · Mar 29, 2019

That one may work https://github.com/benasher44/uuid

The sources of the project use the Kotlin Multiplatform project to implement the UUID library. See https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html for more details