kotlin-native

Clean way of reading all input lines in Kotlin

不打扰是莪最后的温柔 提交于 2019-12-06 05:02:14
A common pattern when doing coding challenges is to read many lines of input. Assuming you don't know in advance how many lines, you want to read until EOF (readLine returns null). Also as a preface, I don't want to rely on java.utils.* since I'm coding in KotlinNative, so no Scanner. I would like to maybe do something like val lines = arrayListOf<String>() for (var line = readLine(); line != null; line = readLine()) { lines.add(line) } But that clearly isn't valid Kotlin. The cleanest I can come up with is: while (true) { val line = readLine() if (line == null) break lines.add(line) } This

Kotlin native interop linker could not find framework

我怕爱的太早我们不能终老 提交于 2019-12-05 09:41:27
I'm trying to use cocoapods framework in Kotlin Multiplatform project. So I added framework to Pods file. ran pod install. created .def file added cinterop config in build.gradle ./gradlew cinteropFirebaseIos runs successfully. It generates .klib so I can see classes in kotlin code. But when I'm trying to run iOS app build fails with message: Showing Recent Messages > Task :app:linkDebugFrameworkIos ld: framework not found FirebaseDatabase /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors Here is my config in build.gradle

Kotlin multiplatform/native interoperability with Objective-C framework

天大地大妈咪最大 提交于 2019-12-03 13:13:23
I'm trying to call Swift/Objective-C code from Kotlin in a multiplatform project. There are no problems with calls to platform code. But when I'm trying to call some library (or framework, not sure how it is properly called as I'm not an iOS dev) it fails. Docs states that it is possible to call Objective-C code and Swift if it is properly exported: Kotlin/Native provides bidirectional interoperability with Objective-C. Objective-C frameworks and libraries can be used in Kotlin code if properly imported to the build (system frameworks are imported by default). See e.g. "Using cinterop" in