kotlin-multiplatform

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

Kotlin multiplatform JVM type mismatch in IntelliJ

拟墨画扇 提交于 2019-12-11 04:49:11
问题 I have a project which contains the following modules: common common-js common-jvm backend web The idea is that I put my shared (kotlin) code (mainly models) in common, which can be used in both the kotlin driven backend and the javascript driven webapp using the recently introduced multiplatform support. To do this, I created a new multiplatform application in Intellij, and added the backend and web modules to it. An example class in the common module: data class Show( val id: Long, val type

Kotlin multiplatform projects run common module test in IDEA

点点圈 提交于 2019-12-10 13:59:39
问题 I am using kotlin multiplatform project with js/jvm subprojects. I used to have unit tests in jvm subproject (annotated using kotlin test annotations) and I easily ran tests using rightclick + Run 'xxx' test using junit. That option is not possible once I move those tests to common module instead. I can still run tests using command line gradle and I even managed to create working Run configuration that worked, but I am missing that simple "right click to run" on class or even specific test

How to create a dynamic proxy in Kotlin common code?

我的梦境 提交于 2019-12-10 11:14:23
问题 If I'm on the JVM I can do this: object Playground { class DynamicInvocationHandler : InvocationHandler { @Throws(Throwable::class) override operator fun invoke(proxy: Any, method: Method, args: Array<Any>): Any { LOGGER.info("Invoked method: {}", method.name) return 42 } companion object { private val LOGGER = LoggerFactory.getLogger( DynamicInvocationHandler::class.java) } } @JvmStatic fun main(args: Array<String>) { val proxy = Proxy.newProxyInstance( Playground::class.java.classLoader,

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

Ktor multiplatform - SSL pinning for iOS in kotlin

三世轮回 提交于 2019-12-08 12:35:23
问题 I am using below code for SSL pinning in Kotlin Multiplatform using Ktor. I am having crash at this line of code val remoteCertificateData : NSData = SecCertificateCopyData(certificate) as NSData Here is the function. override fun URLSession( session: NSURLSession, didReceiveChallenge: NSURLAuthenticationChallenge, completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential?) -> Unit ) { val serverTrust = didReceiveChallenge.protectionSpace.serverTrust val certificate =

How to create a dynamic proxy in Kotlin common code?

荒凉一梦 提交于 2019-12-06 12:13:17
If I'm on the JVM I can do this: object Playground { class DynamicInvocationHandler : InvocationHandler { @Throws(Throwable::class) override operator fun invoke(proxy: Any, method: Method, args: Array<Any>): Any { LOGGER.info("Invoked method: {}", method.name) return 42 } companion object { private val LOGGER = LoggerFactory.getLogger( DynamicInvocationHandler::class.java) } } @JvmStatic fun main(args: Array<String>) { val proxy = Proxy.newProxyInstance( Playground::class.java.classLoader, arrayOf<Class<*>>(MutableMap::class.java), DynamicInvocationHandler()) as MutableMap<String, String>

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