https://kotlinlang.org logo
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

    JoakimForslund

    03/26/2019, 9:03 AM
    I know there is cinterop support, but is it possible to take a existing objective-c library and translate it into kotlin too? And if so, is there an example where this is done?
    o
    • 2
    • 2
  • t

    Thomas

    03/26/2019, 11:42 AM
    Xcode just updated and now I get a crash at runtime when running my iOS app.
    failed to demangle superclass of MainViewController from mangled name '13MyProject22BaseViewControllerCySo16MyItemCSo0G24MyPresenter_pG'
    This is the original line in Swift:
    class MainViewController: BaseViewController<MyItem, MyPresenter>, MyView
    (MyItem, MyPresenter, MyView are Kotlin classes) I found this in the release notes under "Known Issues" (https://developer.apple.com/documentation/xcode_release_notes/xcode_10_2_release_notes/swift_5_release_notes_for_xcode_10_2):
    Linking against a static Swift library might create a binary with missing type metadata because the object files that define the metadata inside the static archive are mistakenly considered unused. (47598583)
    
    This can manifest as a Swift runtime error with a message such as: “failed to demangle superclass of MyClass from mangled name ‘<mangled name>’”.
    
    Workaround: If you can rebuild the static library, try building it with whole module optimization enabled. Otherwise, add -all_load to the linker flags in the client binary to ensure all object files are linked into it.
    I tried adding the all_load linker flag to my Xcode project but there was no difference, but I might have added it wrong as I am very new to Xcode. Could anyone help me out?
    s
    l
    • 3
    • 32
  • u

    uli

    03/26/2019, 12:04 PM
    As Swift5 is now released with stable ABI, I guess it's time to ask for the plans regarding direct Swift interop again 🙂 I do understand that the unstable ABI was enough of a reason not to go for Swift introp yet. But I also understand that it was not the only reason. Any updates on that topic for the kotlin fans waiting?
    ➕ 2
    s
    k
    +7
    • 10
    • 101
  • a

    alexcouch

    03/27/2019, 2:57 AM
    It's like no matter what changes I make to what, it still gives me that linker error. I have no idea what's going on
    m
    • 2
    • 9
  • a

    alexcouch

    03/27/2019, 4:38 AM
    Would I be able to somehow get wchar_tVar as a ByteVar and then get it as a KString?
    m
    u
    s
    • 4
    • 10
  • k

    Kris Wong

    03/27/2019, 1:46 PM
    I wonder how hard it would be for cinterop to support obj-c++? for instance, the only difference in my header files is that the forward declarations use namespacing. I understand it would be more problematic if there were c++ headers included.
    i
    • 2
    • 5
  • k

    kenji_otsuka

    03/27/2019, 2:23 PM
    Hello, I'm trying to connect to internet with Kotlin/Native (macOS), but it doesn't work. Could anyone tell me where is wrong? https://stackoverflow.com/questions/55349254/how-can-i-connect-through-http-in-kotlin-native-ios-development https://github.com/KenjiOhtsuka/macos_kotln_native
    object WebGateway {
        fun get(urlString: String): String {
            val semaphore = dispatch_semaphore_create(0)
    
            val components = NSURLComponents(urlString)
            val url = components.URL
            var result: String = ""
            val config = NSURLSessionConfiguration.defaultSessionConfiguration()
            config.waitsForConnectivity = true
            config.timeoutIntervalForResource = 300.0
    
            val request = NSURLRequest.requestWithURL(url!!)
            val session = NSURLSession.sessionWithConfiguration(
                config, null, NSOperationQueue.mainQueue()
            )
    
            val task =
                session.dataTaskWithRequest(request) { nsData: NSData?, nsurlResponse: NSURLResponse?, nsError: NSError? ->
                    nsData?.run { result = toString() }
                    println(nsData)
                    dispatch_semaphore_signal(semaphore);
                }
    
            task.resume()
            session.finishTasksAndInvalidate()
            NSOperationQueue.mainQueue().waitUntilAllOperationsAreFinished()
            dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER)
            return result
        }
    }
    when i execute
    main.kexe
    , any meaningful output doesn't appear but the program doesn't finish.
    s
    • 2
    • 5
  • d

    Daniel Baird

    03/27/2019, 7:01 PM
    Hi! Could anyone tell me how I can use an object that I have a CPointer to? I'm trying to use the posix readdir method like so:
    var entry = readdir(dp)
    . The entry that is returned is a CPointer<dirent>. I want to use the dirent directly to get the name. One Attempt was to do this
    val name = entry[0].d_name.toString()
    , but that is giving me a useless string that looks like this "CPointer(raw=0x2904670)"
    d
    • 2
    • 3
  • m

    Michael Bryant

    03/27/2019, 9:13 PM
    Is there any way to deal with inheritance when using K/N as a dynamic library? I was hopeful I’d be able to cast the pointers and access different attributes of different classes, but that doesn’t appear to be the case. A simple Kotlin setup I’m trying is
    abstract class Parent(val a: Int) {}
    
    class Child(val b: Int, a: Int) : Parent(a) {}
    
    fun make_thing(): Parent {
        return Child(1, 2);
    }
    s
    • 2
    • 4
  • s

    sksk

    03/28/2019, 2:07 AM
    Hi, there are still no plans to add support for value types ?
    g
    k
    e
    • 4
    • 13
  • l

    lsk

    03/28/2019, 7:04 AM
    Hi, I have a C API where I am passing
    staticCFunction
    handler as a reference to my Kotlin function. I can pass a context (a pointer) to the handler. How to pass more structured data, like data class? Primitives are not enough in my case. Can you advice?
    s
    • 2
    • 6
  • h

    Hauke Radtki

    03/28/2019, 12:37 PM
    Is it possible for cinterop to also compile the library I'm referencing instead of only generating the bridge code?
    o
    d
    • 3
    • 5
  • t

    Thomas

    03/29/2019, 4:32 PM
    Hello, I just upgraded Kotlin to the latest EAP and am unable to export a framework for Xcode. These are the versions I'm using: Kotlin: 1.3.30-eap-125 Kotlin coroutines: 1.1.1-eap13-125 Serialization: 0.11.0-1.3.30-eap-125 Ktor: 1.2.0-alpha-1.3.0-eap-125 This is the error: https://gist.github.com/Thomas-Vos/c2255004d64261d75f7fc715b242f8ee I'm not sure what this error means, could someone let me know what is going wrong?
    s
    o
    l
    • 4
    • 18
  • m

    marcinmoskala

    03/29/2019, 11:23 PM
    Are there platform types in Kotlin/Native?
    t
    n
    +2
    • 5
    • 10
  • l

    lsk

    03/30/2019, 12:26 PM
    in
    .def
    file, how can I reference my project’s
    .h
    files? Nothing like
    headers = ./headers/mine.h
    does not work. I dont want reference full project path here
    d
    • 2
    • 4
  • s

    se1by

    03/30/2019, 7:19 PM
    Hey, I noticed that if you create a new K/N project with either IntelliJ or CLion, it will build a gradle project using the multiplattform plugin. is the kotlin native gradle plugin deprecated?
    l
    n
    • 3
    • 2
  • s

    se1by

    03/30/2019, 11:47 PM
    I think I found a somewhat interesting problem: I just converted my native project to a mpp as I was having unrelated problems with code completion. I moved my native code to a sourceset I called commonNative. But as this is just a sourceset and not a target, I can't add any cinterop libraries. Compilation still works, but the interop packages are shown as unknown (which is right, the libraries are only known at compile time as they are defined in the actual targets). Any ideas on how I could fix this?
    r
    • 2
    • 2
  • a

    alexcouch

    03/31/2019, 4:22 AM
    This is now no longer a problem with the lib but my own problem that I would like to solve for future reference. When linking with the original dll it compiles and links just fine
    m
    s
    • 3
    • 13
  • t

    thevery

    04/01/2019, 4:51 PM
    message has been deleted
    g
    • 2
    • 2
  • j

    JoakimForslund

    04/02/2019, 11:52 AM
    Is there an alternative in in the kotlin ios target which does the same as
    if #available(iOS 11, *) {
    ?
    s
    • 2
    • 3
  • m

    mben

    04/02/2019, 12:05 PM
    Hello i've tried to implement http call with ktor in mmp project using this link https://ktor.io/clients/http-client/multiplatform.html, i can get the result but i have no idea how to get the status code, anyone else tried this solution?
    u
    • 2
    • 7
  • j

    josephivie

    04/03/2019, 5:21 AM
    Is there any documentation on the annotation
    @ObjCMethod(selector, bridge)
    ? I'm trying to figure out how selectors work with Kotlin/Objective C, as I'm trying to work with UI elements from Kotlin.
    s
    o
    • 3
    • 5
  • b

    basher

    04/03/2019, 9:25 PM
    Anyone know what we're supposed to link in mingw for the
    FOLDERID_Documents
    constant/symbol? It's in
    platform.windows.*
    , but we're getting this linker error:
    undefined reference to `FOLDERID_Documents'
    d
    o
    m
    • 4
    • 8
  • a

    azeDevs

    04/06/2019, 9:21 PM
    What is the simplest implementation of a function that runs on an interval timer in Kotlin/Native? I'm only finding solutions for Kotlin/JVM so far.
    h
    s
    • 3
    • 2
  • j

    Joao Zao

    04/08/2019, 12:13 AM
    Getting the following error while trying to cinterop FirebaseAnalytics:
    Task :common-client:linkDebugFrameworkIOS
    Undefined symbols for architecture x86_64:
      "_sqlite3_bind_blob", referenced from:
          ___47-[APMSqliteStore bindValues:toStatement:error:]_block_invoke in GoogleAppMeasurement(APMSqliteStore_ae86ae290f270c42720d24e61ec7eef9.o)
    ....
    My
    .def
    file
    linkerOpts
    👇
    linkerOpts = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.1/lib/darwin/libclang_rt.osx.a -framework FirebaseFirestore -framework BoringSSL -framework gRPC-C++ -framework gRPC-Core -framework gRPC-ProtoRPC -framework gRPC-RxLibrary -framework gRPC -framework leveldb-library -framework Protobuf -framework FIRAnalyticsConnector -framework Firebase -framework FirebaseAnalytics -framework FirebaseCore -framework FirebaseCoreDiagnostics -framework FirebaseInstanceID -framework GoogleAppMeasurement -framework GoogleUtilities -framework nanopb -framework Protobuf -framework StoreKit
    It seems I’m missing the sqlite3 library, how can I add it?
    t
    y
    • 3
    • 4
  • h

    Hauke Radtki

    04/08/2019, 9:09 AM
    Has anyone thought about testing c code in Kotlin/Native? pros/cons?
    ❓ 1
    • 1
    • 1
  • d

    drofwarcs

    04/09/2019, 3:30 PM
    I'm trying to add a custom declaration to my def file to help aid cinterops with a mocking library for iOS. The method is as follows
    _Nullable id verify(id mock) {
         return  MKTVerifyWithLocation(mock, self, __FILE__, __LINE__);
    }
    cinterops throws
    error: use of undeclared identifier 'self'
    . Is cinterops not able to handle the
    self
    keyword yet or is there another way I should be handling this?
    o
    s
    • 3
    • 12
  • m

    mben

    04/09/2019, 3:34 PM
    Hello i just started exploring dependency injection in hybdrid, app any one tried kodein alongside with kotlin native? does it work in ios app?
    u
    l
    • 3
    • 14
  • a

    azeDevs

    04/09/2019, 7:43 PM
    What am I misunderstanding about K/N Coroutines that is preventing this from ever running:
    fun startUiLoop() {
        GlobalScope.launch {
            delay(32L)
            updateUi()
        }
    }
    d
    s
    +2
    • 5
    • 6
  • t

    Tobi

    04/10/2019, 7:52 AM
    Hey folks, I am currently working on a multiplatform library involving some hashing and looking for an equivalent for
    String.toByteArray()
    , which is just available on the jvm (https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/to-byte-array.html). Any idea how I could do this using kotlin/native or just the common stdlib? https://kotlinlang.slack.com/archives/C3PQML5NU/p1554881432104600
    a
    s
    • 3
    • 4
Powered by Linen
Title
t

Tobi

04/10/2019, 7:52 AM
Hey folks, I am currently working on a multiplatform library involving some hashing and looking for an equivalent for
String.toByteArray()
, which is just available on the jvm (https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/to-byte-array.html). Any idea how I could do this using kotlin/native or just the common stdlib? https://kotlinlang.slack.com/archives/C3PQML5NU/p1554881432104600
cc @addamsson
a

addamsson

04/10/2019, 8:03 AM
thx
s

svyatoslav.scherbina

04/10/2019, 8:41 AM
Does anything prevent you from using this function: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.native/to-utf8.html ?
t

Tobi

04/10/2019, 10:25 AM
Just the fact that I didn’t know about it 💯
View count: 5