I'm trying to use SocketRocket Objective-C library on my Kotlin MPP project and I need to import it using cinterop, but I can't seem to find it.
There is Kotlin Multiplatform Gradle plugin. The plugin delivers the cinterop tool for you. You may find more documentation here:
https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#cinterop-support
You may also follow one of (to be updated) tutorials for Kotlin/Native with the explanation on how to find the conterop tool
https://kotlinlang.org/docs/tutorials/native/interop-with-c.html
Related
I just wanted to taste Kotlin coroutines. Unfortunately, I haven't been able to use the library kotlinx in IntelliJ. I have downloaded the library through Maven.
Tried invalidating caches.
Rebuilt project.
Tried using it in a fresh project.
Even IntelliJ is suggesting kotlinx in auto-completion.
Still it says unresolved reference
I have tried most of the solutions on the web. But nothing worked.
Here are the steps that I am exactly doing.
Made a new project.
kotlinx is underlined since the library has not been added.
In project structure > modules > dependencies > add > library > maven Searched for the kotlinx library.
Downloaded the library.
Applied the settings.
kotlinx library is now visible in the External Libraries section.
Even the auto-completion is now suggesting kotlinx.
Still, nothing changes. The result is the same.
I have found the answer in the Kotlin slack channel. And to solve this particular issue add org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.0 instead of org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0.
However, it is generally a good idea to learn a build system like Gradleor Maven and using those in the project. It makes life a lot easier.
I have a kotlin project that is compiled to java.
My test library is junit.
Im using maven as my dependency management and Intellij IDEA.
recently I got that strange warning in my pom.
Inspection info: If you have kotlin-test and junit dependency then
most likely you better to include kotlin-test-junit instead of just
kotlin-test
What is the difference between kotlin-test and kotlin-test-junit?
from what I read it seems that kotlin-test is not deprecated, so Why did intellij recommend kotlin-test-junit instead of kotlin-test?
So I found the answer here (I don't understand how I missed it in my first search)
In short kotlin-test library provides a set of annotations and utility functions independently of the test framework.
Where kotlin-test-junit library provides an implementation on top of Junit Asserter and the annotations and utility functions kotlin-test provides.
Within JetBrains tutorial is this info regarding creating new Kotlin project
But I can see only this --> i.e. without Project Template
Both the Idea and tutorial is for IntelliJ 2020.2 (I use Community Edition, but I did not find any note regarding different tutorials for different editions)
I am probably missing something... but don't know what
edit:
I would say that I have Kotlin plugin installed
Upgrade the Kotlin Plugin in IntelliJ IDEA to version 1.4. The new project wizard has been introduced in Kotlin 1.4.
I would like to try to build Kotlin/Native project with dependencies on some library.
As documentation explains, I need to create def file (which I was already created) and run cinterop tool.
However, I wasn't able to find this tool on my Mac and curious how this could be installed.
Can you please give me some advice?
I strongly advise you to use Gradle + Kotlin MPP plugin. Not only it will provide cinterop support, but it will ease further development, testing, and multiplatform support. It works on any OS, of course.
If you need an example, here is the official one for the cURL library: https://github.com/JetBrains/kotlin-native/blob/master/samples/libcurl/build.gradle.kts. Note the cinterops block under compilations["main"].
The nice thing about Kotlin MPP plugin is that it actually allows you to play with the Kotlin/Native tools directly. It will download the tools specifically for your platform automatically on the first run and place them in ~/.konan directory. So if you really want to use cinterop tool from CLI you'll be able to find it there: ~/.konan/kotlin-native-macos-1.3.61/bin/cinterop. klib and kotlinc are there as well.
I've found a blog post that describes how to use CPD on an Objective-C project. The author also provided a CPD language library for ObjectiveC. Unfortunately, the GUI provided by the Violations plugin in Jenkins is rather ugly. The visualization that Sonar uses is much more helpful in analyzing the code.
The following command is used to generate the corresponding CPD output:
java
-Xmx512m
-classpath pmd-4.2.5.jar:ObjCLanguage-0.0.6-SNAPSHOT.jar
net.sourceforge.pmd.cpd.CPD
--minimum-tokens 100
--files [Path to XCode project classes]
--language ObjectiveC
--encoding UTF-8
--format net.sourceforge.pmd.cpd.XMLRenderer > cpd-output.xml
As far as I know, the project language can be configured in the Sonar plugin configuration at Jenkins. But how can I tell Sonar to use the ObjCLanguage library? I only need this for detecting code duplication and visualization by Sonar (since it is so much prettier).
If you want to have analysis results in Sonar, you need to install a Sonar plugin that brings support for the language. However, there's currently no plugin for Objective-C, so you won't be table to get what you're trying to achieve... unless you develop this plugin! ;-)
There seems to be ongoing work on an Objective-C plugin for Sonar. You may find it at https://github.com/fhelg/sonar-objective-c
I have also seen another Objective-C plugin for Sonar:
https://github.com/octo-technology/sonar-objective-c