kotlin-native

Kotlin Native iOS string formatting with vararg

隐身守侯 提交于 2021-02-08 04:59:50
问题 Based on this issue about using NSString formatting I try to implement multiplatform implementation for formatting when using vararg , with no luck so far. What I did added FoundationInterop.def language = Objective-C --- #import <Foundation/NSString.h> NSString* format(NSString* format, ...) { va_list args; va_start(args, format); NSString* result = [[NSString alloc] initWithFormat:format arguments:args]; va_end(args); return result; } compiled it in gradle targets { final def iOSTarget =

Where to put gradle dependencies block in kotlin native project generated by Intellij IDEA?

时光毁灭记忆、已成空白 提交于 2020-05-15 22:44:56
问题 I'm trying to make my first app in Kotlin Native. I want to add TornadoFX to my freshly created project. I need to add a dependency according to TornadoFX guide dependencies { compile 'no.tornado:tornadofx:x.y.z' } The issue is - I cant figure out where exactly do I put it . This is my build.gradle contents (generated by IntelliJ IDEA): plugins { id 'org.jetbrains.kotlin.multiplatform' version '1.3.60' } repositories { mavenCentral() } kotlin { // For ARM, should be changed to iosArm32 or

Android Studio: jump to definition (cmd+click) from android code to kotlin/native code goes to decompiled .class instead of .kt

只谈情不闲聊 提交于 2020-04-16 02:59:07
问题 I have a project for android that uses an own library with kotlin/native to share it with iOS app. I started it with this tutorial. It's working perfectly, already on production, so I'm very happy with it but I have one problem that I'm not able to solve: In Android Studio, when I cmd+click a kotlin/native function from the android project class (also kotlin) it goes to decompiled .class file instead of the .kt file. This make it much slower to debug or just implement new functions. I tried

Kotlin native interop linker could not find framework

本小妞迷上赌 提交于 2020-01-22 20:47:22
问题 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

How to convert const char* to KString in Kotlin/Native?

橙三吉。 提交于 2019-12-13 16:25:46
问题 In a C++ file, I want to convert a const char* to KString, so that I can then pass the KString to a Kotlin file using Kotlin/Native. I believe the answer lies in the function OBJ_GETTER(utf8ToUtf16, const char* rawString, size_t rawStringLength) that I found in KString.cpp. But even though I discovered the used define statements in Memory.h, I have not yet managed to properly call the function utf8ToUtf16 from my own C++ file to get a KString. Any help is appreciated. 回答1: It depends on how

Adding a `.klib` library to kotlin multiplatform

a 夏天 提交于 2019-12-13 03:32:42
问题 I'm wondering how I'd be able to import my cinterop-ted library to gradle build of the kotlin multiplatform build. I've already created the library.def file and filled it, I also generated the library.klib and the folder that goes with it. I just don't understand how to import it into gradle. I've looked all over internet and I found a reference to Konan and I'm wondering if that's something I have to use, or if that's something being used for something similar to 'cinterop'. I've looked over

Kotlin Native cinterop def file: how to eliminate absolute path?

ⅰ亾dé卋堺 提交于 2019-12-11 14:41:51
问题 When specify linkerOpts, we need set absolute path for -L option, but it's easy to break. In older version, setting linkerOpts in build.gradle could work, but in 1.3.50, it warns that "-linker-option(s)/-linkerOpts/-lopt option is not supported by cinterop. Please add linker options to .def file or binary compilation instead.", and build do fail with "Undefined symbols" error. What could I do? 回答1: This option is going to be deprecated once, so the warning was intentionally added after the 1

Does kotlin-native have destructors?

血红的双手。 提交于 2019-12-10 12:56:19
问题 In kotlin native there is memScoped function that automatically free allocated memory when control is going out of scope. Is there something like destructors for local objects? 回答1: Current Kotlin/Native does not provide mechanism for calling a method when certain object is no longer needed in memory (finalizer in Java speech) but inline lambdas easily allow to implement mechanisms, similar to RAII in C++. For example, if you want to be sure, that some resource is always released after

Kotlin multiplatform/native interoperability with Objective-C framework

百般思念 提交于 2019-12-09 05:59:58
问题 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

Clean way of reading all input lines in Kotlin

 ̄綄美尐妖づ 提交于 2019-12-08 00:21:06
问题 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