• Javier

    Javier

    2 years ago
    I am having problems to run test from terminal
    Task 'test' not found in root project 'MyRootProject'
    , But I can run jvmTest via IntelliJ without problems
    Javier
    mbonnin
    4 replies
    Copy to Clipboard
  • Amanjeet Singh

    Amanjeet Singh

    2 years ago
    Need a piece of advice, I was writing a repository in
    commonMain
    using coroutines. Normally, the methods in android would be marked by
    suspend
    and then they can fetch any data from remote or local. Also writing tests to this on JVM (Android in my case) is easy as we can create a
    runBlocking
    and assert the results. But when it comes to iOS we don't have any
    suspend
    methods and thus the same function cannot be tested and thus we end up adding a high order function which will give you an
    onSuccess
    or
    onFailure
    when
    launch
    coroutine gives result. This seems to be a bit messy to me because in common we end up maintaining 2 implementations for fetching same data each for android and iOS. (common is not "common" anymore in this case) I need an approach which can be directly exposed to both worlds with unit tests also working on both sides. How you guys create repositories and unit test them? Advices and approaches would be appreciated 🙂
    Amanjeet Singh
    e
    +3
    22 replies
    Copy to Clipboard
  • Victor Grigorev

    Victor Grigorev

    2 years ago
    Hello! I wanna try to use Periphery (https://github.com/peripheryapp/periphery) static code analyzer in my iOS project, but I get error using Periphery script via the terminal:
    Undefined symbols for architecture arm64:
    "_OBJC_CLASS_$_IosCombinedDialogModelAlign", referenced from:
    objc-class-ref in StringExtensions.o
    "_OBJC_CLASS_$...
    ...
    ld: symbol(s) not found for architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    What I need to do?
    Victor Grigorev
    Artyom Degtyarev [JB]
    5 replies
    Copy to Clipboard
  • s

    Sean Keane

    2 years ago
    Hi All! I have a project where im building for Android , iOS and JS and I'm wondering what is the best time library to use for all three platforms? I tried Klock but it gives me JS issues.
    s
    e
    3 replies
    Copy to Clipboard
  • z

    ZabGo

    2 years ago
    I am trying Kotlin Multiplatform on a Mac to develop an iOS app.  I cannot access UIDevice, I get “unresolved reference: UIDevice”.  Does someone have any idea where the issue could come from? I am maybe missing something in my gradle config. The android studio kotlin plugin has the version 1.3.72. Thanks in advance for your help! Here my gradle files Build.gradle (project)
    buildscript {
      ext.kotlin_version = '1.3.72'
      repositories {
        google()
        jcenter()
         
      }
      dependencies {
        classpath 'com.android.tools.build:gradle:3.6.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"
    
    
    
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
      }
    }
    
    allprojects {
      repositories {
        google()
        jcenter()
         
      }
    }
    build.gradle(module)
    plugins {
      kotlin("multiplatform")
    }
    
    Kotlin{
    iosX64("ios"){
      binaries {
        framework {
          baseName = "SharedCode"
        }
      }
    }
    
    jvm("android")
    
    
      sourceSets["commonMain"].dependencies {
        implementation("org.jetbrains.kotlin:kotlin-stdlib-common")
        implementation("io.ktor:ktor-client-core:1.3.2")
        implementation("io.ktor:ktor-client-json:1.3.2")
        implementation("io.ktor:ktor-client-serialization:1.3.2")
      }
    
      sourceSets["androidMain"].dependencies {
        implementation("org.jetbrains.kotlin:kotlin-stdlib")
        implementation("io.ktor:ktor-client-android:1.3.2")
    
      }
    
      sourceSets["iosMain"].dependencies{
        implementation("org.jetbrains.kotlin:kotlin-stdlib")
        implementation("io.ktor:ktor-client-ios:1.3.2")
        implementation("io.ktor:ktor-client-json-native:1.3.2")
        implementation("io.ktor:ktor-client-serialization-native:1.3.2")
    
      }
    }
    z
    p
    +1
    53 replies
    Copy to Clipboard
  • s

    Shawn Karber_

    2 years ago
    I am running into some issues I didn't expect porting some Kotlin code that I wrote into Kotlin Multiplatform. It works in a standalone Kotlin app, but not in Kotlin Multiplatform, and I'm assuming they have to be written differently in common.kt? Any suggestions on how to fix these common uses:
    fun convertHexToBitString(dataString: String) : String {
                val binaryArray: MutableList<String> = arrayListOf()
                dataString.toCharArray().forEach {
                    val binValue =
                        if (it.isDigit()) {
                            String.format("%4s",
                                           Integer.toBinaryString(Character.getNumericValue(it)))
                                           .replace(' ', '0')
                        } else {
                            when(it.toUpperCase()) {
                                'A' -> "1010"
                                'B' -> "1011"
                                'C' -> "1100"
                                'D' -> "1101"
                                'E' -> "1110"
                                'F' -> "1111"
                                else -> "Invalid hexadecimal digit in string."
                            }
                        }
                    binaryArray.add(binValue)
                }
                return binaryArray.joinToString("")
    it.isDigit() is not working in common.kt, nor is Character.getNumericValue, and neither is String.format(). Are any of these accessible through another means in Kotlin Multiplatform?
    s
    s
    +1
    3 replies
    Copy to Clipboard
  • m

    Madhan

    2 years ago
    Hi All, Is it possible to use existing android project for multiplatform project to share my network layer between android and ios.
    m
    Foso
    +1
    4 replies
    Copy to Clipboard
  • e

    edenman

    2 years ago
    anybody already written a common kotlin
    val Char.isEmoji: Boolean
    helper? The Char api is pretty limited and all my stackoverflow results are jvm or iOS specific
    e
    saket
    4 replies
    Copy to Clipboard
  • mbonnin

    mbonnin

    2 years ago
    When running macosX64 tests, how can I read a resource file ? Or have access to the test directory, similar to
    System.getProperty("user.dir")
    on the JVM ?
    mbonnin
    1 replies
    Copy to Clipboard
  • c

    curioustechizen

    2 years ago
    I don't know if this should be here or in #kotlin-native but here goes: Is
    resumeWith
    on
    kotlin.coroutines.Continuation
    a mutating operation? If so, how can I share it with another thread in order to bridge callback-style APIs and suspend functions? My scenario: I have a suspend function in a shared API (shared between Android and iOS). On Android I just implement it as a regular suspend function. On iOS, I'm attempting to use
    continuation
    and call it from my callback. • If I freeze the continuation object I receive
    InvalidMutabilityException
    , • if I don't freeze it, I receive
    IncorrectDereferenceException
    . I'm using coroutines 1.3.5-native-mt
    c
    2 replies
    Copy to Clipboard