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
  • s

    spierce7

    05/23/2018, 9:20 PM
    What is the performance hit for freezing an object? If I freeze an object that has references to other objects, are they frozen as well? Let's say I have an object hierarchy of ~1000 objects, and freeze the root object. Why kind of performance hit are we talking about?
    o
    l
    • 3
    • 5
  • n

    napperley

    05/23/2018, 11:48 PM
    Kotlin Native has some server-side samples, could that be extended to cover Serverless? Is Serverless development going to be officially supported in Kotlin Native?
    g
    o
    +3
    • 6
    • 59
  • s

    spierce7

    05/24/2018, 11:40 PM
    It looks like there is an attempt to creating a kotlin mocking library for java and js: http://mockk.io/ It seems to me they won't be able to support Kotlin-native, or is there some creative way that I'm unaware of that mocking in Kotlin-native / the C world is possible?
    a
    • 2
    • 3
  • a

    apatrida

    05/25/2018, 5:19 AM
    Question, what does a SWIFT optional look like from the viewpoint of Kotlin. A nullable value, or something that is like
    Optional
    class?
    o
    • 2
    • 2
  • n

    norman784

    05/25/2018, 12:25 PM
    or maybe the
    vertexBuffer
    or
    vertexArrayId
    isn’t set the right way, those parts are so strange and awkward for me, I do something similar in Swift and was straight forward
    o
    • 2
    • 3
  • a

    adev_one

    05/25/2018, 9:12 PM
    Can I make generated Swift protocol properties covariant? My case: Kotlin:
    interface Article {
        val id: Int
        val category: Category
    }
    
    interface Category {
        val id: Int
    }
    Swift:
    @objc
    class RealmArticle: Object, KNArticle {
        @objc dynamic var id: Int32 = 0
        @objc dynamic var category: RealmCategory = RealmCategory() // type does not conform to protocol KNArticle
    }
    
    @objc
    class RealmCategory: Object, KNCategory {
        @objc dynamic var id: Int32 = 0
    }
    s
    • 2
    • 1
  • s

    spierce7

    05/25/2018, 9:38 PM
    Is it safe to use Swift objects in multiple Kotlin threads, assuming proper concurrency synchronization is handled? Does this change if it's a Kotlin object that extends a Swift object?
    o
    • 2
    • 1
  • n

    norman784

    05/28/2018, 11:51 AM
    I’m so confused by the bindings generated by konan, don’t understand how to call this function, it is supposed to be just like this:
    val vertexShaderSource: String = "...."
    val vertexShader = glCreateShader(GL_VERTEX_SHADER)
    glShaderSource(vertexShader, 1, vertexShaderSource, null)
    Tried different thinks like
    .toCValues()
    ,
    .cValuesOf()
    ,
    .cstr.getPointer(this /* memscoped reference */)
    , I find so complicated some of the bindings, don’t know if theres a better way to detect that the variable is a char array and do automatically the convertion between string a char array (and vice versa) This is how the
    glShaderSource
    looks like in kotlin
    public fun glShaderSource(shader: platform.OpenGLCommon.GLuint /* = <http://kotlin.Int|kotlin.Int> */, count: platform.OpenGLCommon.GLsizei /* = <http://kotlin.Int|kotlin.Int> */, string: kotlinx.cinterop.CValuesRef<kotlinx.cinterop.CPointerVar<platform.OpenGLCommon.GLcharVar /* = kotlinx.cinterop.ByteVarOf<platform.OpenGLCommon.GLchar /* = kotlin.Byte */> */> /* = kotlinx.cinterop.CPointerVarOf<kotlinx.cinterop.CPointer<kotlinx.cinterop.ByteVarOf<platform.OpenGLCommon.GLchar /* = kotlin.Byte */>>> */>?, length: kotlinx.cinterop.CValuesRef<platform.OpenGLCommon.GLintVar /* = kotlinx.cinterop.IntVarOf<platform.OpenGLCommon.GLint /* = kotlin.Int */> */>?): kotlin.Unit { /* compiled code */ }
    And this is the c function
    void glShaderSource(	GLuint shader,
     	GLsizei count,
     	const GLchar **string,
     	const GLint *length);
    s
    • 2
    • 2
  • d

    drofwarcs

    05/30/2018, 1:26 AM
    Typically in iOS when creating UITableViewController subclass, its easy to have that subclass implements the UITableViewDataSource and UITableViewDelegate protocols. When doing so in K/N I get a "Conflicting Overloads" error for
    override fun tableView(tableView: UITableView, cellForRowAtIndexPath: NSIndexPath): UITableViewCell
    from the data source protocol and
    override fun tableView(tableView: UITableView, didSelectRowAtIndexPath: NSIndexPath)
    from the delegate protocol . Is this a known issue and is there a work around besides putting the two methods in different classes?
    g
    s
    • 3
    • 10
  • f

    fabianterhorst

    05/30/2018, 10:32 AM
    whats the best ide to use for kotlin native on ios? I have tried clion and appcode but none had autocompletes for the platform imports.
    o
    v
    d
    • 4
    • 5
  • s

    Sam

    05/30/2018, 2:18 PM
    Post your actual lipo command. The part that confused me at first was that I was only providing the path to the
    .framework
    directory and expecting lipo to do the right thing. In reality I had to provide the full path to the binary inside of the framework directory. Once you have that done you’ll want to copy the headers and
    .plist
    file from one of the source frameworks to your new framework directory.
    y
    • 2
    • 1
  • y

    yusuf3000

    05/31/2018, 1:34 PM
    I’m trying to run
    xcodebuild
    from command line, and i have a shell script in my project that runs gradlew :
    "$SRCROOT/../../../gradlew"
    . If i build from xcode, it works completely fine, but if i do it from command line then the operation hangs on this line indefinitely. Does anyone know why this would be happening?
    o
    j
    • 3
    • 25
  • j

    james

    05/31/2018, 3:00 PM
    Hi, concerning build time is there anything that can make it faster ?
    o
    s
    s
    • 4
    • 4
  • k

    Konstantin Petrukhnov

    06/01/2018, 6:14 AM
    any idea about this problem? https://kotlinlang.slack.com/archives/C9JM6Q2UX/p1527762085000028
    s
    • 2
    • 1
  • o

    olonho

    06/01/2018, 1:51 PM
    some people asked about GCD usage example, here you go: https://github.com/JetBrains/kotlin-native/pull/1641
    👍 1
    🎉 1
    s
    • 2
    • 2
  • r

    russhwolf

    06/04/2018, 12:44 AM
    If I have
    MyObject.Companion.foo()
    in kotlin code compiling to a framework, what’s the proper way to access it from Swift? The only thing I can figure out how to do is
    MyObjectCompanion.init().foo()
    , but that doesn’t seem right because I don’t want to be creating a new instance of the companion object.
    s
    k
    +2
    • 5
    • 18
  • y

    yusuf3000

    06/04/2018, 2:11 PM
    Related to above issue: if i have a kotlin enum with a companion object, the objc/swift companion object does not have the same methods as the non companion version so i cannot call any methods on it. Is this expected behavior?
    s
    • 2
    • 1
  • s

    Sam

    06/04/2018, 2:47 PM
    Understanding that the new stuff from Apple today isn’t production ready, what’s the level of effort to compile a Kotlin Native framework against the iOS 12 sdk? I’m assuming it isn’t as simple as Xcode-select but maybe I’m wrong? 🤞
    l
    s
    • 3
    • 2
  • k

    Konstantin Petrukhnov

    06/06/2018, 11:05 AM
    Is there way to build framework for swift and not for ObjectiveC?
    o
    s
    +2
    • 5
    • 8
  • b

    breandan

    06/06/2018, 1:44 PM
    Is anyone using Kotlin Native for robotics?
    o
    n
    • 3
    • 2
  • s

    spierce7

    06/07/2018, 3:23 PM
    When are we going to see Kotlin/native 0.8?
    o
    • 2
    • 1
  • d

    drofwarcs

    06/08/2018, 4:32 AM
    Does the K/N plugin for Appcode make any additional changes to project settings(project.pbxproj) besides adding the "Compile Kotlin/Native" build phase?
    v
    • 2
    • 1
  • o

    olonho

    06/08/2018, 4:24 PM
    @channel Kotlin/Native team is pleased to announce release v0.7.1 of our toolchain. This is a bugfixing release, including the following features: * Bugfixes in the runtime (indexOf, GC for kotlin.Array, enum equality) and the compiler * Fix NSBlock problem, preventing upload of binaries to the AppStore * Create primitive type boxes and kotlin.String as frozen by default * Support Gradle 4.7, provide separate run task for each executable * Support XCode 9.4 and CoreML and ClassKit frameworks on Apple platforms * Improved runtime Kotlin variable examination * Minor performance optimizations in compiled code and runtime * Add
    disableDesignatedInitializerChecks
    definition file support Binaries: * https://download.jetbrains.com/kotlin/native/builds/releases/0.7.1/macos/kotlin-native-macos-0.7.1.tar.gz * https://download.jetbrains.com/kotlin/native/builds/releases/0.7.1/linux/kotlin-native-linux-0.7.1.tar.gz * https://download.jetbrains.com/kotlin/native/builds/releases/0.7.1/windows/kotlin-native-windows-0.7.1.zip GitHub release page is https://github.com/JetBrains/kotlin-native/releases/tag/v0.7.1
    🎉 7
    n
    • 2
    • 6
  • n

    napperley

    06/09/2018, 9:41 PM
    Does JetBrains have a Kotlin Native Docker image that can be used with OpenFaaS (https://www.openfaas.com/)?
    v
    o
    • 3
    • 2
  • n

    napperley

    06/10/2018, 4:39 AM
    Round trip for the Kotlin Native one is 0.015s vs 0.581s for the Python one 😀 .
    👍 4
    o
    s
    • 3
    • 6
  • g

    gildor

    06/10/2018, 10:14 AM
    I have a question about Kotlin MPP libraries publishing for Kotlin/Native Currently you can publish library as .klib that contains binaries for multiple targets, but it looks like not a perfect solution for pure K/N library, as library author I would like to publish library for K/N (without platform-specific code) so other K/N projects could use it, but building and publishing binaries for particular platform is not flexible enough, for example you cannot publish library for macos using linux CI or just publish for any non-cross-compiled targets. Is there any consideration to allow publish IR or even source code K/N compatible libraries (as klib or any other format) that can be used easily by any K/N project. And yeah, I heard about idea to use IR as a format for distribution of Kotlin libraries, but looks like this is not near future plan, and it’s not critical for JVM or JS, but for K/N this looks like a way to publish libraries is much more flexible and the only really platform-independent way. Maybe it would be nice to try with K/N even if it’s impossible to do for other Kotlin platforms
    o
    • 2
    • 6
  • k

    kartikpatodi

    06/10/2018, 5:22 PM
    Can we use a module wiritten in K/N with a Kotlin-JVM module?
    a
    g
    s
    • 4
    • 3
  • r

    rkeazor

    06/10/2018, 7:21 PM
    does Kotlin native have a solution for making network requests yet?
    o
    • 2
    • 1
  • d

    drofwarcs

    06/10/2018, 11:38 PM
    If you're targeting iOS you can use its platform specific api NSURLSession
    n
    • 2
    • 2
  • n

    norman784

    06/11/2018, 3:17 PM
    I’m having issues understanding and making to work OpenGL with Kotlin, I’ve done some progress in last few days, but is so slow, the issue I’m facing is that cannot load textures, followed a lot of different C tutorials and tried to migrate them to Kotlin, but it just doesn’t work, The texture is supposed to show one in front of the other in a rectangle, but seems that is not rendered (I just saw a coloured rectangle instead of the texture), I’ve uploaded an example here https://github.com/norman784/kotlin-native-opengl-tutorial/blob/master/src/5-ATexturedCube/main.kt
    g
    o
    • 3
    • 11
Powered by Linen
Title
n

norman784

06/11/2018, 3:17 PM
I’m having issues understanding and making to work OpenGL with Kotlin, I’ve done some progress in last few days, but is so slow, the issue I’m facing is that cannot load textures, followed a lot of different C tutorials and tried to migrate them to Kotlin, but it just doesn’t work, The texture is supposed to show one in front of the other in a rectangle, but seems that is not rendered (I just saw a coloured rectangle instead of the texture), I’ve uploaded an example here https://github.com/norman784/kotlin-native-opengl-tutorial/blob/master/src/5-ATexturedCube/main.kt
g

gaetan

06/11/2018, 6:02 PM
I don’t know if it can be of any help, but 2 weeks ago I just published a small code using WebGL to do heatmap rendering with kotlin. https://github.com/data2viz/webglheatmap-kotlin/blob/master/src/main/kotlin/WebGLHeatmap.kt
o

olonho

06/12/2018, 7:51 AM
OpenGL is not very easy to follow API, so maybe higher level wrapper written in Kotlin style would be nice. We cannot invest in such wrapper ourselves at the moment, but would welcome community contribution.
👍 1
n

norman784

06/12/2018, 10:02 AM
I’ve been working on a wrapper myself, and thats why I follow the opengl tutorial, to test with the opengl interop to later on wrap around to be easier to work with. https://github.com/norman784/lwkgl
@gaetan wil check it out your repo, thanks
@olonho found where the issue is (but I’ve not solved yet, https://github.com/norman784/kotlin-native-opengl-tutorial/blob/master/src/5-ATexturedCube/main.kt#L64-L71) basically seems that I’m not passing correctly the last parameter and thats why the texture isn’t rendered, because the colors and texture coords in the shader are 0, can you point me the right direction to fix this? Btw tried to pass the pointer of an IntVar without luck, if I set the last parameter of
glVertexAttribPointer
null it works kinda (but with the vertex coordinates)
o

olonho

06/13/2018, 3:06 PM
maybe https://github.com/JetBrains/kotlinconf-spinner/blob/5322d90e5a125d69eba61d5aee1bf48386096126/kotlin-native/samples/fullstack/clients/shared/src/main/kotlin/gl.kt#L54 would help you
n

norman784

06/13/2018, 3:57 PM
I already checked and use the same method, but with the last parameter null, in my case I need to pass the last parameter to tell opengl where to look for the color and the uv coordinates, check this
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(3 * sizeof(float)));
maybe I can reformulate te question and ask how can I translate to kotlin this
(void*)(3 * sizeof(float))
, tried with
cValuesOf(3 * FloatVar.size)
and
val pointer: FloatVar = alloc(); pointer.value = 3 * FloatVar size; glVertexAttribPointer(...., pointer.prt);
o

olonho

06/13/2018, 4:33 PM
if using 12 as value of
void*
is what you indeed want, then
12.toLong().toCPointer()
is what you need
n

norman784

06/13/2018, 4:49 PM
I get
error: type inference failed: Not enough information to infer parameter T in fun <T : CPointed> Long.toCPointer(): CPointer<T>?
Please specify it explicitly.
o

olonho

06/13/2018, 4:52 PM
right,
12.toLong().toCPointer<COpaque>()
😘 1
n

norman784

06/13/2018, 4:56 PM
thanks, it works like a charm!
View count: 6