kotlin-native | Kotlin/Native infrastructure | Compiler library
kandi X-RAY | kotlin-native Summary
kandi X-RAY | kotlin-native Summary
Kotlin/Native infrastructure
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of kotlin-native
kotlin-native Key Features
kotlin-native Examples and Code Snippets
Community Discussions
Trending Discussions on kotlin-native
QUESTION
I have a multiplatform library to do few APIs calls with Ktor (2.0.0-beta-1)
...ANSWER
Answered 2022-Feb-03 at 17:09If you're using the latest version of ktor and coroutines, you'll probably want to use the new memory model, and just the 1.6.0
kotlinx.coroutines rather than the native-mt version.
https://github.com/touchlab/KaMPKit/blob/main/gradle.properties#L26
Most library dev from Jetbrains will likely focus on the new memory model from now on, so unless there are specific near term concerns on moving, I would do that.
QUESTION
I am trying to write a simple multiplatform library for Android and iOS. My dependencies are:
...ANSWER
Answered 2021-Sep-13 at 08:28The latter error suggests you to synchronize the Kotlin version you're using and the Ktor version. Check the Recommended kotlinx library versions for details. Probably, you will need to change the Kotlin to 1.5.30, or downgrade the Ktor 1.5.4.
Please comment below with the result. I'll update this answer if something will be still wrong.
QUESTION
I would like to make an http request with ktor on Windows with kotlin multiplatform. My gradle configuration looks like this:
...ANSWER
Answered 2021-Jun-30 at 09:37The gradle sync fails because CIO engine only supports java, and any dependency included in common part should be multiplatform(native).
Just move implementation("io.ktor:ktor-client-cio:$ktorVersion")
into jvmMain
dependencies.
There's no engine that can be added to common code, so you need to add an appropriate engine for each platform you support, and HttpClient()
will pick one of them by itself. Check out documentation for more details
QUESTION
I followed Get started with Kotlin/Native using the command-line compiler, downloaded kotlin-native-linux-1.5.10.tar.gz and added its bin
to the PATH
of system. Now which kotlinc-native
returns true value.
But when I try kotlinc-native hello.kt -o hello
, get this error:
ANSWER
Answered 2021-Jun-20 at 09:51As a workaround, you can manually install libtinfo.so.5 to your system
e.g Linux distro package manager
QUESTION
Based on the documentation: Subclassing Swift/Objective-C classes and protocols from Kotlin I am trying to subclass a SwiftUI class in Kotlin native. I found some examples for UiKit but no examples for SiwftUI.
This is what I tried so far:
...ANSWER
Answered 2021-May-03 at 09:57Kotlin/Native
does not offer interop with pure Swift. Currently it works indirectly with a K\N
- Obj-C
- Swift
interop. Direct interoperability with Swift
is on the roadmap, but it's currently paused AFAIK
From the documentation:
Kotlin/Native provides bidirectional interoperability with Objective-C" ... "A Swift library can be used in Kotlin code if its API is exported to Objective-C with @objc. Pure Swift modules are not yet supported.
Since SwiftUI
is pure Swift, you can't really import it to Kotlin unfortunately (hopefully yet).
QUESTION
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
ANSWER
Answered 2020-Oct-27 at 08:01I confirm what you say about NSString.stringWithFormat
. The feature is missing as we read in the JB offical answer from
Svyatoslav Scherbina and we could follow the issue from you here: KT-42925
As an awful workaround, I was suggesting something like that (WARNING: not exhaustive, without many index count checks...)
QUESTION
I try to archive in XCode 12 a project referencing a Kotlin Native framework with cocoapods plugin, but it fails with message like this (using iPhone SE to build archive)
...ANSWER
Answered 2020-Oct-20 at 13:23building for iOS-armv7 but attempting to link with file built for iOS-arm64
Looks like you're trying to archive for armv7, which (I think) is 32 bit ios, or maybe watch, etc. Most apps need just arm64, and your Xcode framework will only be arm64 according to this:
QUESTION
I've been struggling to solve a problem.
I'm building a cross platform app (iOS and Android) using Kotlin Multiplatform (KMP) where I need a library from Google (https://github.com/google/libphonenumber).
For Android, I can point to a Maven repo (https://repo1.maven.org/maven2/com/googlecode/libphonenumber/libphonenumber/8.12.6/).
For iOS, I can use a ObjC port of libPhonenumber via Cocoapods.(https://cocoapods.org/pods/libPhoneNumber-ios).
But, I can't use Kotlin's (cocoapod plugin) to properly recognize the Pod. The plugin appears to fail to build. Here's the details of my setup:
- Xcode v11.5
- IntelliJ IDEA v2020.1.2
- Cocoapods v1.9.1
- Gradle 6.0.1
- Sample repo (https://github.com/touchlab/kotlin-native) NOTE: Within the repo, I'm using ./samples/cocoapods
- modify ./samples/cocoapods/kotlin-library/build.gradle.kts
commented out AFNetworking, remove AFNetworking pod
pod("AFNetworking", "~> 3.2.0")
add a new podpod("libPhoneNumber-iOS")
- modify ./samples/cocoapods/kotlin-library/gradle.properties
change this line:
kotlin.native.home=../../../dist
to this:#kotlin.native.home=../../../dist
- in Terminal in this folder: ./samples/cocoapods/kotlin-library/
./gradlew podspec
This creates a podspec file (libPhoneNumber-iOS.def) in ./samples/cocoapods/kotlin-library/build/cocoapods/defs/ - cd from kotlin-library to ios-app folder
cd ../ios-app/
- Pod install using the command:
pod install
You'll see something like:
ANSWER
Answered 2020-Jul-13 at 09:06This particular problem seems to be caused by the dash in the pod's name. There was already an issue reported on GitHub. For now, it's recommended to workaround this problem by re-naming the module. Changing your kotlin-library/build.gradle.kts
like
QUESTION
I'm exploring Kotlin Native and have a program with a bunch of Workers doing concurrent stuff (running on Windows, but this is a general question).
Now, I wanted to add simple logging. A component that simply logs strings by appending them as new lines to a file that is kept open in 'append' mode.
(Ideally, I'd just have a "global" function...
...ANSWER
Answered 2020-Jan-22 at 17:38The approach you've taken is pretty much correct and the way it's supposed to be done.
The thing I would add is, instead of passing around a pointer around. You should pass around a frozen FileLogger
, which will internally hold a reference to a AtomicRef
, the the attaching and detaching should be done internally. Especially since DetachedObjectGraph
s are invalid once attached.
QUESTION
I'm experimenting with Kotlin native and iOS. I tried to use the example at raywenderlich as a starting point. This example is a bit old , so I have updated the code to fit the Kotlin multiplatform 1.3.61. I'm using AppCode to build the code.
I'm struggling with the Kotlin DSL gradle file ( build.gradle.kts) , the example is using build.gradle :
...ANSWER
Answered 2020-Jan-10 at 12:33Maybe it will make sense to check the contents of your result .klib to make sure you use the correct package name. It can be done using ~/.konan/kotlin-native-macos-1.3.61/bin/klib
CLI tool.
Also, I would recommend you to take a look at this sample from the Kotlin/Native Github, it also utilizes AFNetworking and uses the latest compiler version.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install kotlin-native
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page