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

    ankushg

    10/06/2021, 7:33 PM
    Does anyone have tips for improving iterative/debug KMP/iOS workflows without having a monorepo setup? Current setup: We currently have separate repos for our shared libraries and iOS app (
    quizlet-kmp
    and
    quizlet-ios
    ). Our current approach is that `quizlet-kmp`'s CI builds the framework and publishes it to our private spec repo. iOS folks can then just pull the latest version. Problem: This approach has worked fine for us for the past while, but some issues with this approach that are starting to get annoying are: 1. It takes a lot of time to iterate within KMP and test the change on iOS. Having to push, wait for a release to be published, update your podfile, etc is time consuming. We want an opt-in way to allow iOS folks to develop using locally checked out KMP sources. 2. We can't drop breakpoints into the KMP code to debug issues on iOS. My understanding is that this is impossible to do unless you've built the code locally. What we're thinking: 1. The official Kotlin/Native Cocoapods Plugin seems to address issue 1 if we use it in an opt-in way (defaulting to CI builds instead). 2. Touchlab's xcode-kotlin plugin for Xcode seems to address issue 2 if the framework is built locally (and I think it's designed to be used alongside the cocoapods plugin?) Both of the examples for these tools are using a monorepo setup though. Has anyone gotten them working with separate, independent repos? I think I should be able to get the cocoapods plugin working by pointing the ios app's
    Podfile
    to the absolute path of `quizlet-kmp`'s generated Podspec (regardless of directory). This could be conditionally done for every iOS engineer, since the Podfile is just a ruby script. I also think the xcode-kotlin plugin should also allow me to drag in files from any arbitrary directory. I'd love to hear if anyone else has done so and can confirm!
    m
    r
    +5
    • 8
    • 29
  • k

    KamilH

    10/07/2021, 5:44 AM
    Is it possible to catch exceptions thrown by Swift/Objective-C code? I’m integrating a library whose methods are throwing various exceptions (
    NSException
    ) and I would like to catch and handle them, is it possible? I can see that the documentation mentions that it’s not yet possible, but maybe some work has been done in this topic? Is there any issue I can star and follow?
    Note that the opposite reversed translation is not implemented yet: Swift/Objective-C error-throwing methods aren’t imported to Kotlin as exception-throwing.
    s
    • 2
    • 1
  • m

    martmists

    10/10/2021, 9:03 PM
    How do I turn a string into a
    CPointer<ByteVar>
    ? I only see
    .cstr
    documented but that turns it into a
    CValues<ByteVar>
    m
    d
    • 3
    • 7
  • m

    martmists

    10/11/2021, 12:12 PM
    strangely enough it crashes either in my function or before it depending on what functions I have defined somehow?
    g
    • 2
    • 6
  • g

    Gavin Ray

    10/12/2021, 2:25 PM
    I believe I've seen several repos (include JetBrains' own) using JNI to write functions that get used in both JVM apps, and in Kotlin Native. If true, how does this work? Since JNI requires the
    JNIEnv*
    param implicit in all calls. Or am I out of my mind haha
    u
    n
    l
    • 4
    • 6
  • g

    Gavin Ray

    10/12/2021, 2:42 PM
    Not sure how KN is transparently calling
    Java_org_jetbrains_skija_Canvas__1nDrawPicture
    without (what looks like) passing any
    JNIEnv
    🤔
    a
    o
    s
    • 4
    • 15
  • b

    Benoit Quenaudon

    10/12/2021, 7:10 PM
    Yo I'm trying to get the target of a symlink in posix. I'm trying
    realpath
    (platform.posix.realpath) but for some reason, a
    private
    prefix is added on the resolved path. Any idea why that could be? Code is something like that
    val fullpath = realpath(path.toString(), null)
            try {
              symlinkTarget = Buffer().writeNullTerminated(fullpath).toPath()
            } finally {
              free(fullpath)
            }
    And my test fails with
    kotlin.AssertionError: Expected </base/symlink-target>, actual </private/base/symlink-target>.
    e
    u
    • 3
    • 16
  • b

    Benoit Quenaudon

    10/12/2021, 8:02 PM
    How does one adds parameters to a native call? Like there is
    fun realpath(arg0: String?, arg1: CValuesRef<stat>?): Int
    In the console, there are multiple params like
    --logical
    ,
    --zero
    , etc. How do we set those up when calling from Kotlin native?
    e
    • 2
    • 5
  • b

    Bailey Pollard

    10/13/2021, 7:03 PM
    Has anyone have experience with what causes a
    SIGSEGV: Attempted to dereference garbage pointer 0xe480162a0.
    ? Total iOS noob here, but any suggestions could help
    :not-kotlin: 1
    m
    • 2
    • 1
  • m

    MiSikora

    10/14/2021, 8:44 AM
    What is the reason that
    dispatcher
    gets frozen after launching the job? I noticed it does not happen when
    channel
    is a global value. I’m having issues wrapping my head around it.
    class FreezeTest {
      private val dispatcher = ImmediateDispatcher()
      private val callbacks = AtomicReference(emptyList<() -> Unit>().freeze())
    
      @Test
      fun freezeTest() = runBlocking(dispatcher) {
        println("1 isFrozen: ${dispatcher.isFrozen}") // False
        val job = launch {
          val channel = Channel<Unit>()
          val callback: () -> Unit = { channel.trySend(Unit) }
          callbacks.update { it + callback }
          try {
            for (signal in channel) {
              channel.send(Unit)
            }
          } finally {
            callbacks.update { it - callback }
          }
        }
        println("2 isFrozen: ${dispatcher.isFrozen}") // True
        job.cancel()
      }
    }
    
    fun <T> AtomicReference<T>.update(func: (T) -> T) {
      while (true) {
        val old = value
        val new = func(old).freeze()
        if (compareAndSet(old, new)) break
      }
    }
    
    class ImmediateDispatcher : CoroutineDispatcher() {
      override fun dispatch(context: CoroutineContext, block: Runnable) = block.run()
    }
    t
    • 2
    • 6
  • a

    altavir

    10/17/2021, 8:04 AM
    Could anyone explain why I get frozen collection mutation in this code? It is marked as ThreadLocal.
    👀 1
    b
    r
    • 3
    • 19
  • j

    jw

    10/18/2021, 5:07 PM
    Where can I find an example of allocating an array of structs in order to pass a
    CValuesRef
    to the leading item + item count to a C function? I've done with things like ByteArray where I can call
    refTo(0)
    but I don't see an explanation or example of how to do this with a struct type.
    m
    g
    • 3
    • 13
  • g

    Gavin Ray

    10/21/2021, 4:16 PM
    Is there any reason why instead of only being able to generate definitions from
    C .h -> Kotlin Native type
    you could write a compiler plugin that did codegen and emitted an
    .h
    ?
    interface SomeStruct {
        @CType.Int32
        val anInt: Int
    }
    typedef struct SomeStruct {
      int32_t anInt;
    } SomeStruct;
    s
    • 2
    • 1
  • t

    TheOnlyTails

    10/21/2021, 6:10 PM
    Hi, I wanna try making some stuff with Kotlin/Native for the Wasm target, and I saw that IDEA doesn't have good support for kotlin native. What should I use? (I have access to the all-products pack)
    s
    n
    • 3
    • 2
  • j

    jimmyt

    10/21/2021, 11:04 PM
    I'm trying to add a dependency on a CocoaPod with custom cinterop options, as described here. I want cinterop to pass "-fmodules" and "-fcxx-modules" to the compiler, and so I'm using the following bit inside the cocoapods block of my build.gradle.kts file:
    pod("MatrixSDK"){
                extraOpts = listOf("-compiler-options = -fmodules -fcxx-modules")
    }
    But I continue to get an error that says:
    Exception in thread "main" java.lang.IllegalStateException: Unknown option -compiler-options = -fmodules -fcxx-modules
    I'm clearly just using the command wrong, but I can't find any documentation for proper use anywhere. Can someone help me out with this?
    v
    • 2
    • 3
  • p

    Philip Dukhov

    10/22/2021, 2:27 PM
    I'm trying to confirm
    KotlinEnum
    to
    Identifiable
    with the following code:
    extension KotlinEnum: Identifiable {
        public var id: Int32 { ordinal }
    }
    but the build fails with the following:
    Extension of a generic Objective-C class cannot access the class's generic parameters at runtime
    I don't understand the problem, as
    ordinal
    has strict type
    Int32
    , not a generic one. How can I bypass it?
    r
    • 2
    • 1
  • a

    ankushg

    10/22/2021, 8:33 PM
    Not sure if this belongs here, or #gradle, but I'm trying to understand why our build times for release artifacts are so painfully slow. We have a multi-module, multi-platform build, and it looks like linking iOS Frameworks is taking 2/3 of our total build time. After running a build scan, it looks like our
    linkReleaseFramework<Target>
    tasks (
    KotlinNativeLink
    ) are starting late in the build and executing serially, even though there are plenty of idle workers available. Things got much worse once we added M1 support since there was now yet another framework to link 😕 The
    KotlinNativeLink
    tasks don't seem to depend on each other in any way. Are these tasks supposed to be able to run in parallel? If so, how can I find out why they aren't for our builds? If not, is there a YT ticket for this? Screenshot/description of build scan timeline in 🧵
    😱 2
    ➕ 4
    👀 3
    r
    t
    +2
    • 5
    • 28
  • j

    jean

    10/25/2021, 6:52 AM
    I’m trying to run some sql queries within a transaction by using
    databaseQueries.transactionWithResult { ... }
    (SQLDelight) but it throws the following error :
    kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen kotlin.Array@10f1738
    it works correctly on my android target. Am I suppose to do/use something else?
    • 1
    • 1
  • n

    Nicolas Patin

    10/25/2021, 10:05 AM
    Hi everyone. I need to check app notifications settings on the device, and in order to do this, I use the following snippet for the iOS target :
    actual suspend fun areNotificationsSystemEnabled() : Boolean = suspendCoroutine { continuation ->
        val settingsCompletionHandler = { settings: UNNotificationSettings? ->
            val enabled = settings?.authorizationStatus == UNAuthorizationStatusAuthorized
            continuation.resume(enabled)
        }.freeze()
    
        val notificationCenter = UNUserNotificationCenter.currentNotificationCenter()
        notificationCenter.getNotificationSettingsWithCompletionHandler(settingsCompletionHandler)
    }
    My problem here is that the “continuation” used inside the completion handler is frozen, so it crashes on the
    continuation.resume(enabled)
    :
    Uncaught Kotlin exception: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen kotlin.coroutines.SafeContinuation@80487928
    [...]
        at 7   KMM                                 0x00000001071d43e0 kfun:kotlin.coroutines.SafeContinuation#resumeWith(kotlin.Result<1:0>)
    I think my issue is more or less the same than this one : https://youtrack.jetbrains.com/issue/KT-43566 I don’t know if I should ask this on #coroutines but if anyone already hit this issue, I’ll be glad to hear from you 😄 Thanks !
    r
    • 2
    • 2
  • y

    Yashar

    10/25/2021, 3:10 PM
    This might be an old issue already solved in
    0.7.1
    https://kotlinlang.slack.com/archives/C3SGXARS6/p1528475089000678 but I wanted to get another opinion from the community. Our dynamic scanner has identified a use of private iOS API:
    Frameworks/Core.framework/Core: _unsymbolicated_function accessed _NSBlock
    within a KMP library module. Upon some digging, I came across this similar old issue on github with fix already merged. So my question is, has anyone else come across this? And if so, is this issue already addressed and have folks been fine publishing to App store without rejections?
    o
    s
    • 3
    • 6
  • m

    Michael Clancy

    10/25/2021, 4:59 PM
    Hi there, have had a look around and can’t seem to find the recommended solution to this. If I am calling an obj-C function from native, and this function returns a List<*>, (due to limited generics in obj-C), how might I cast to a DoubleArray if I know the type in the collection?
    r
    • 2
    • 2
  • n

    napperley

    10/26/2021, 1:42 AM
    I have completely forgotten how to setup a Kotlin Native project (for a Kotlin Native program) to use a dreaded C header only library 😱. The library being used in this case is LVGL ( https://lvgl.io/ ) via its Linux Frame Buffer ( https://kevinboone.me/linuxfbc.html?i=1 ) backend. At one point I had a Kotlin Native project that successfully used a C header only library (the third party library provided some GTK Chart widgets) but can't find it 😦. @Artyom Degtyarev [JB] - Can someone please advise on how to use a C header only library in a Kotlin Native project that will generate a Linux program (an ELF binary).
    a
    • 2
    • 9
  • m

    Marc Reichelt

    10/26/2021, 1:20 PM
    Hey there! I’m trying to build a KMP project into 3 targets: arm64 (real device) plus x64 and arm64 for simulator. I’m using the
    ./gradlew createSwiftPackage
    command, which in turn creates an xcframework using KMP’s tooling. However, the built framework only contains x64 simulator and arm64 (real device) code, so the simulator on my MacBook M1 will not run. Did anyone successfully build an xcframework for all 3 targets, that is also able to run on M1 simulators as well as on Intel simulators?
    👍 1
    r
    • 2
    • 5
  • s

    Sylvain Patenaude

    10/26/2021, 1:55 PM
    I upgraded to kotlin 1.5.31 in the last few days and I'm getting this error when compiling in iOS:
    @SharedImmutable is applicable only to top level declarations
    and also this one in enums:
    @SharedImmutable is applicable only to val with backing field or to property with delegation
    Example of data class:
    data class SomeDataClass(
        @SharedImmutable val someInt: Int,
        @SharedImmutable val someString: String,
        @SharedImmutable val someBool: Boolean
    )
    Example of enum class:
    enum class SomeEnumClass(
        /** The [Int] representation of this enum value. */
        @SharedImmutable val value: Int
    ) {
        @SharedImmutable ValueA(0),
        @SharedImmutable ValueB(1);
    
        companion object {
            internal fun fromInt(value: Int) = values().firstOrNull() { it.value == value } ?: ValueA
        }
    }
    • 1
    • 3
  • c

    crumpf

    10/26/2021, 3:28 PM
    After upgrading to Big Sur, the cinterop task for cocoapod dependencies is failing. Anyone have any idea what might be going on? System OS: macOS Big Sur version 11.6 Android Studio: Arctic Fox 2020.3.1 Patch 3 I tried creating a new KMM Application project using CocoaPods for the iOS framework distribution step. After creating the project a gradle sync works fine. Then I add
    pod("AFNetworking")
    to the
    cocoapods
    section of the build.gradle.kts. When I try to do a gradle sync after that the following error appears:
    Execution failed for task ':shared:cinteropAFNetworkingIos'.
    > Process 'command '/Users/me/Library/Java/JavaVirtualMachines/corretto-16.0.2/Contents/Home/bin/java'' finished with non-zero exit value 1
    
    * Try:
    Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':shared:cinteropAFNetworkingIos'.
    	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:187)
        <36 internal calls>
    Caused by: org.gradle.process.internal.ExecException: Process 'command '/Users/me/Library/Java/JavaVirtualMachines/corretto-16.0.2/Contents/Home/bin/java'' finished with non-zero exit value 1
    	at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:414)
    	at org.gradle.process.internal.DefaultJavaExecAction.execute(DefaultJavaExecAction.java:52)
    	at org.gradle.process.internal.DefaultExecActionFactory.javaexec(DefaultExecActionFactory.java:198)
    	at org.gradle.api.internal.project.DefaultProject.javaexec(DefaultProject.java:1145)
    	at org.jetbrains.kotlin.compilerRunner.KotlinToolRunner.runViaExec(KotlinToolRunner.kt:102)
    	at org.jetbrains.kotlin.compilerRunner.KotlinToolRunner.run(KotlinToolRunner.kt:77)
    	at org.jetbrains.kotlin.gradle.tasks.CInteropProcess.processInterop(KotlinNativeTasks.kt:1017)
        <122 internal calls>
    v
    • 2
    • 2
  • a

    ankushg

    10/26/2021, 9:06 PM
    Anyone have some gradle magic that they use to override the filename and
    spec.name
    that the cocoapods plugin generates? We use an umbrella module with a name like
    xcode-umbrella
    but... that's not the name we want for our actual cocoapod. Setting
    framework.baseName
    works for the final
    .framework
    and the value for what's included in the Podspec, but doesn't impact the
    spec.name
    or actual
    *.podspec
    filename
    r
    • 2
    • 3
  • g

    gaetan

    10/27/2021, 12:04 PM
    I have an iOS application that uses some shared code that itself depends on a Kotlin multiplatform library. iOS.app -> shared -> library I’m trying to develop a timer that uses
    CADisplayLink
    in the Kotlin code. This is the code of my “timer”:
    @ThreadLocal
    object AppTimer {
    
       fun start(){
          val selector = NSSelectorFromString("execution")
          val displayLink = CADisplayLink.displayLinkWithTarget(this, selector)
          displayLink.addToRunLoop(NSRunLoop.currentRunLoop, NSRunLoop.currentRunLoop.currentMode)
       }
    
       @ObjCAction
       fun execution(){
          NSLog("AppTimer::Execution through CADisplayLink")
       }
    }
    It works without problem if the timer code is located in the shared module. But, when I move it into the library, it throws this error:
    2021-10-27 13:45:35.769237+0200 iOSApp1[21754:6605253] -[App1_kobjcc0 execution]: unrecognized selector sent to instance 0x6000026025e0
    2021-10-27 13:45:35.793415+0200 iOSApp1[21754:6605253] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[App1_kobjcc0 execution]: unrecognized selector sent to instance 0x6000026025e0'
    *** First throw call stack:
    (
    	0   CoreFoundation                      0x00007fff20422fba __exceptionPreprocess + 242
    	1   libobjc.A.dylib                     0x00007fff20193ff5 objc_exception_throw + 48
    	2   CoreFoundation                      0x00007fff20431d2f +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
    	3   CoreFoundation                      0x00007fff204274cf ___forwarding___ + 1455
    	4   CoreFoundation                      0x00007fff204297a8 _CF_forwarding_prep_0 + 120
    Does anyone have an idea of why this is happening?
    • 1
    • 1
  • r

    reactormonk

    10/27/2021, 6:47 PM
    Looks like no dagger in kotlin-native - is there a drop-in replacement?
    🇳🇴 3
    m
    k
    • 3
    • 3
  • a

    ankushg

    10/27/2021, 10:13 PM
    Is there a known issue with
    xcodeConfigurationToNativeBuildType
    in Gradle Cocoapods plugin in 1.5.31? In Xcode, we have a custom configuration named
    Development
    In Gradle, we're setting
    xcodeConfigurationToNativeBuildType["Development"] = NativeBuildType.DEBUG
    But we still see this in our logs:
    Unable to detect Kotlin framework build type for CONFIGURATION=Development automatically. Specify 'KOTLIN_FRAMEWORK_BUILD_TYPE' to 'debug' or 'release'
    It looks like it's still building the debug framework, but would love to know if • this is already known, • we're doing something wrong, • or if we should file a YT
    a
    v
    • 3
    • 5
  • i

    ianrumac

    10/28/2021, 1:44 PM
    Hey folks! I’m using kotlinc-native to compile a simple program, no main since it will be loaded externally. If I run
    kotlinc-native test.kt -nomain
    it fails with
    “could not find ‘main’ in ‘<root>’ package.”
    Same thing happens until I strictly provide a entry point with -e and the entry point method needs to have either 0 args or an arg array. Is there a way to compile it without having a main method? I thought
    -nomain
    option does that already but it just turns out ignored 🤔
    fun run(args: Array<String>, result: Test){
        val array = args
        array[0] = "42"
        result.res(array[0])
    }
    
    interface Test {
        fun res(string: String)
    }
    m
    • 2
    • 3
Powered by Linen
Title
i

ianrumac

10/28/2021, 1:44 PM
Hey folks! I’m using kotlinc-native to compile a simple program, no main since it will be loaded externally. If I run
kotlinc-native test.kt -nomain
it fails with
“could not find ‘main’ in ‘<root>’ package.”
Same thing happens until I strictly provide a entry point with -e and the entry point method needs to have either 0 args or an arg array. Is there a way to compile it without having a main method? I thought
-nomain
option does that already but it just turns out ignored 🤔
fun run(args: Array<String>, result: Test){
    val array = args
    array[0] = "42"
    result.res(array[0])
}

interface Test {
    fun res(string: String)
}
m

mkrussel

10/28/2021, 1:55 PM
Without a main you are not creating a program. Instead I'm guessing you need to build a library. I don't know how to do that, but that would be what I would start researching.
i

ianrumac

10/28/2021, 2:25 PM
@mkrussel as soon as I read the message I realised what a dumbass I was, I forgot to include “-produce library” 😂 thanks for the solution <3
oh well it goes down the drain since I cant produce a lib for wasm 😢
View count: 19