https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
kotlin-native
  • j

    juliocbcotta

    06/25/2018, 11:54 PM
    So Kotlin native does not have yet a package dependency tool.. right?
    g
    • 2
    • 1
  • j

    juliocbcotta

    06/25/2018, 11:54 PM
    something like npm, maven, apt...
    r
    • 2
    • 1
  • n

    napperley

    06/26/2018, 4:07 AM
    Getting stuck with translating a C Macro (creates a Struct? - https://www.eclipse.org/paho/files/mqttdoc/MQTTClient/html/_m_q_t_t_client_8h.html#aefd7c865f2641c8155b763fdf3061c25) into a custom def declaration (https://github.com/JetBrains/kotlin-native/blob/master/INTEROP.md#adding-custom-declarations) that will create a instance of MQTTClient_connectOptions (generated class in the KLib). This is part of a Kotlin Native program which uses the Eclipse Paho MQTT Client library (https://www.eclipse.org/paho/clients/c/).
    m
    o
    +2
    • 5
    • 14
  • a

    amorenew

    06/26/2018, 7:37 AM
    For using Kotlin Native in iOS do I need to learn c++? or Just Kotlin and Swift? especially if I want to develop a cross platform libraries in Kotlin Native like KNArch.db
    o
    t
    +2
    • 5
    • 6
  • r

    rjhdby

    06/26/2018, 9:54 AM
    Hi! I'm try using konanc in linux inside corporate network without any possibility of internet access. Can I install all dependencies manually, without "Downloading native dependencies (LLVM, sysroot etc). This is a one-time action performed only on the first run of the compiler."?
    g
    s
    • 3
    • 8
  • m

    Mohit Gurumukhani

    06/26/2018, 10:28 PM
    Hi! I am using Kotlin/Native to develop multiplatform projects including iOS through appcode. I was wondering how do you use storyboard to have connection outlets to Kotlin files? With XCode and Swift, we can just use control+drag thingy. But, XCode does not do that for Kotlin files. Yet, the default project by appcode for Kotlin/Native for iOS already has outlet connections to Kotlin files. I was wondering how could we add more objects and have outlets for them too. Of course, not using storyboard is an option but that sample project actually does use storyboard!
    v
    s
    o
    • 4
    • 4
  • n

    napperley

    06/27/2018, 2:05 AM
    Is there a way to wrap a CVariable into a CValuesRef?
    o
    • 2
    • 5
  • a

    amorenew

    06/27/2018, 5:45 AM
    I wonder what is the advantage of using Kotlin native over React Native ?
    o
    s
    +2
    • 5
    • 10
  • r

    rjhdby

    06/27/2018, 12:02 PM
    What is the difference between kotlinc and konanc?
    o
    • 2
    • 1
  • s

    spierce7

    06/27/2018, 4:57 PM
    @olonho Is there anything different of the performance characteristics with the kotlin/native reference counting implementation than other languages like Swift or Rust?
    o
    • 2
    • 3
  • m

    Mohit Gurumukhani

    06/27/2018, 6:29 PM
    Hi! I am using Kotlin/Native to develop multiplatform project and was wondering how should I structure the project and which IDE to use? Like should we have android, ios, js etc. as separate modules in the same project? Or should we have a separate project for ios and separate for say common+android+js with each as modules. And then we could use Gradle to link this project with iOS. Also, how would this playout with the IDE for each project?
    a
    a
    +2
    • 5
    • 9
  • a

    amorenew

    06/27/2018, 7:15 PM
    I wonder what this mean Android's switch to LLVM/Clang as the default platform compiler in Android 7.0 is Android already using LLVM like ios?not JVM https://android-developers.googleblog.com/2018/06/compiler-based-security-mitigations-in.html
    d
    m
    • 3
    • 4
  • a

    AnaR

    06/27/2018, 7:53 PM
    To use Audio Toolbox on iOS via Kotlin Native, I have the following code: var url = NSBundle.mainBundle.URLForResource(file, "mp3") var id:Int = 0 val status = AudioServicesCreateSystemSoundID(url, cValuesOf(id)) AudioServicesPlaySystemSound(id) However, the url should be CFURLRef for AudioServices instead of NSURL returned by the URLForResource method. I tried bridging using: var cfurl = CFBridgingRetain(url) as CFURLRef val status = AudioServicesCreateSystemSoundID(cfurl, cValuesOf(id)) But, that throws a class cast. Not casting as CFURLRef results in a compiler error. Appreciate any pointers on what to try.
    s
    • 2
    • 3
  • k

    kpgalligan

    06/27/2018, 9:38 PM
    linkerOpts "-lsqlite3"
    👍 1
    d
    • 2
    • 2
  • n

    napperley

    06/28/2018, 12:34 AM
    Kotlin Native works on the Raspberry Pi 2 (via cross compilation). Is the latest Raspberry Pi (3 Model B+ - https://www.raspberrypi.org/blog/raspberry-pi-3-model-bplus-sale-now-35/) supported as a target?
    o
    • 2
    • 5
  • p

    prada

    06/28/2018, 1:58 AM
    I just wandering if K/N has plan to support armv7/7s for iphone or not.
    o
    • 2
    • 1
  • n

    nicola.de.fiorenze

    06/28/2018, 8:40 AM
    Hi, I have started exploring kotlin native and the integration with iOS, here the repository with all the information I'm collecting. Advices and pull requests are welcome. Enjoy 😁 https://github.com/defio/KotlinNativeExperiments
    👍 2
    y
    t
    • 3
    • 4
  • r

    rjhdby

    06/28/2018, 10:54 AM
    Hi! How the best way to produce object file (somelib.o)? I trying this way:
    kotlinc -opt ./file.kt -o file -produce bitcode
    llc -filetype=obj file.bc -o file.o
    But it does not include standard library and result of
    cc
    compilation is:
    /usr/bin/ld: file.o: relocation R_X86_64_32 against undefined symbol `ktype:kotlin.text.StringBuilder' can not be used when making a shared object; recompile with -fPIC
    o
    • 2
    • 3
  • s

    spierce7

    06/28/2018, 7:10 PM
    In the default Kotlin/native AppCode application demo, I see the following code snippet:
    @ObjCAction
        fun buttonPressed() {
            label.text = "Konan says: 'Hello, ${textField.text}!'"
        }
    It's not clear how the
    @ObjCAction
    is routing to the button that's being pressed. It's also not clear how that button is being selected. Can anyone point me in the right direction?
    v
    d
    • 3
    • 3
  • s

    spierce7

    06/28/2018, 8:40 PM
    I'm trying to set a click listener programmatically in an iOS application, and I'm getting an error because I'm setting the bridge incorrectly. What should the value be for the bridge?
    @ExportObjCClass
    class ViewController : UIViewController {
        constructor(aDecoder: NSCoder) : super(aDecoder)
        override fun initWithCoder(aDecoder: NSCoder) = initBy(ViewController(aDecoder))
    
        @ObjCOutlet lateinit var label: UILabel
    
        @ObjCOutlet lateinit var textField: UITextField
    
        @ObjCOutlet lateinit var button: UIButton
    
        override fun viewDidLoad() {
            super.viewDidLoad()
    
            button.addTarget(this, action=sel_registerName("buttonPressed"), forControlEvents=UIControlEventTouchDown)
        }
    
        @ObjCMethod(selector = "buttonPressed", bridge = "ViewController") fun buttonPressed() {
            label.text = "Konan says: '2, ${textField.text}!'"
        }
    }
    v
    s
    • 3
    • 7
  • s

    spierce7

    06/29/2018, 4:59 AM
    I'm currently using
    initBy(ViewController(aDecoder))
    , but
    initBy
    is deprecated. The message tells me I can replace
    initBy
    with
    @OverrideInit
    on the constructor, but every time I do, I get an error:
    constructor with @OverrideInit doesn't override any super class constructor.
    Is there an example somewhere of how to use this annotation properly? It seems no matter what I do it doesn't work.
    s
    • 2
    • 5
  • m

    Malte

    06/29/2018, 1:36 PM
    Hey guys, our team is currently developing an image processing engine in Kotlin that is used in our Android and in the future also in the iOS app. Currently, its’ an Android library running on the JVM but we need to find a solution to share the code base with iOS (no Android specific code involved). We see these most favourable options: 1. Using Kotlin Native 🚀 2. Using Swift and accessing it via JNI Wrapper on Android (we need to rewrite our Kotlin code to Swift code) 3. Using C++ (which most developers are not familiar with, so option 1 & 2 are definitely our favourites) The problem: K/N is not stable right now and we are worrying how much support it will receive in the future. K/N also never has been used in any production App (apart from Jetbrain’s Conf App). My Questions: 1. Any news on a release date for a stable version of K/N? 2. Do you know any specific company which is using K/N in production? My best guess right now is, that we rather go with Swift or C++ since we can hardly base our future development on sth non-stable 💔 😕 but we would really love to if we know that K/N receives serious amount of development in the next time ❤️ 💃 It’s a big project, so we need to be considerate with our choice of technology. I did a lot of research and I only saw this rather unspecific statement of olonho: https://github.com/JetBrains/kotlin-native/issues/1166
    o
    d
    +7
    • 10
    • 14
  • n

    nwh

    06/29/2018, 8:27 PM
    I have never worked with anything "native" before, only JVM, so I don't know what's possible with K/N. I am wondering: can I interact with an HID device via K/N, or is that is totally out of scope? https://docs.microsoft.com/en-us/windows-hardware/drivers/hid/introduction-to-hid-concepts
    o
    • 2
    • 4
  • d

    damian

    06/30/2018, 2:00 AM
    I noticed recently that Kotlin extensions are no longer exposed to ObjC/Swift as extensions, but instead as classmethods on a somewhat unusually named class... I'm pretty sure that they actually appeared as extensions using an earlier build though. What is the reason for the change? Will be extensions be returning at some point? (Or am I just mistaken?)
    s
    • 2
    • 6
  • s

    spierce7

    06/30/2018, 4:47 AM
    @olonho In response to someone else, you mentioned some things that I wanted to follow up on. You mentioned some improvements that need to be worked on with k/n:
    using the technology in combination with Gradle
    . When you integrate with Gradle, will that be when we finally get incremental compilations? You mentioned that Kotlin 1.3 features need to be added before a stable release as well. Is there a place where I can read about the changes coming in Kotlin 1.3? I haven't been able to find a roadmap or anything for Kotlin 1.3. You mentioned that k/n already shares a code base with jvm and js compilers. Getting the compilers under the same arch and sharing an api is one of the first steps to a public API to 3rd party Kotlin compiler plugins (probably the feature I've been most anticipating). How close are we to that as a reality?
    g
    o
    +3
    • 6
    • 15
  • s

    spierce7

    06/30/2018, 6:15 PM
    How do I add a swift library to a Kotlin/native project?
    a
    o
    • 3
    • 3
  • n

    napperley

    06/30/2018, 11:38 PM
    What software development areas are likely to be supported by Kotlin Native (v1.0 onwards)? Would the following areas be supported: 1. Serverless, a sub area of Server-side 2. Desktop 3. CLI 4. IoT (using a SBC like Rpi, BBB etc), which is a sub area of Embedded 5. Machine Learning 6. AI 7. iOS 8. Android 9. Web Stack (both the web front-end and back-end via WASM)
    o
    n
    k
    • 4
    • 4
  • k

    kpgalligan

    07/01/2018, 6:56 PM
    I have some questions about the gradle plugins. Not sure of best place to ask, so I'll post here. The K/N gradle plugin, 'konan' has a lot of control and options, and you can publish libraries to maven, but as far as I can tell, there's no way to specify those published libraries as dependencies. There's also 'kotlin-platform-native' which can also publish libraries to maven, and can ingest dependencies from maven, but only if they were published by 'kotlin-platform-native'. The 'konan' published dependencies aren't compatible with 'kotlin-platform-native' out of the box.
    r
    • 2
    • 8
  • k

    krtko

    07/02/2018, 5:16 AM
    Any update on if or how Kotlin will handle value types?
    l
    n
    +2
    • 5
    • 5
  • y

    yusuf3000

    07/02/2018, 10:56 AM
    I was wondering if there was a way to alleviate this problem I’m having with kotlin/swift interoperability. I have a generic interface in Kotlin
    interface Repository<T> {
        fun add(model: T): Boolean
    }
    I have another interface that conforms to `Repository`:
    interface TestModelRepository : Repository<TestModel> {
          override fun add(model: TestModel): Boolean
       }
    When I have a class in Swift that conforms to
    TestModelRepository
    class SwiftTestModelRepository: TestModelRepository
    it wants me to implement both
    add
    methods. One with type
    id
    and one with type
    TestModel
    . I only want to implement one of them. Is there a workaround for this where I only implement the overridden one from
    TestModelRespository
    and not from the generic Repository? As a backup I can only declare
    add
    in
    TestModelRepository
    and remove it from
    Repository
    but this will make the code less clean as I want to have many more repositories that conform to
    Repository
    and would like to reuse the
    add
    method.
    s
    • 2
    • 3
Powered by Linen
Title
y

yusuf3000

07/02/2018, 10:56 AM
I was wondering if there was a way to alleviate this problem I’m having with kotlin/swift interoperability. I have a generic interface in Kotlin
interface Repository<T> {
    fun add(model: T): Boolean
}
I have another interface that conforms to `Repository`:
interface TestModelRepository : Repository<TestModel> {
      override fun add(model: TestModel): Boolean
   }
When I have a class in Swift that conforms to
TestModelRepository
class SwiftTestModelRepository: TestModelRepository
it wants me to implement both
add
methods. One with type
id
and one with type
TestModel
. I only want to implement one of them. Is there a workaround for this where I only implement the overridden one from
TestModelRespository
and not from the generic Repository? As a backup I can only declare
add
in
TestModelRepository
and remove it from
Repository
but this will make the code less clean as I want to have many more repositories that conform to
Repository
and would like to reuse the
add
method.
s

svyatoslav.scherbina

07/02/2018, 12:02 PM
Thank you for providing this case. Unfortunately, Swift seems to imply restrictions that are stricter than expected: Swift compiler doesn’t consider these two methods with same Objective-C selector as the same method. As a workaround, you can stop using generics here.
y

yusuf3000

07/02/2018, 12:13 PM
Ah okay, thanks
s

svyatoslav.scherbina

07/02/2018, 12:40 PM
Also this Kotlin interface can be implemented in Objective-C.
View count: 7