Sabrina Namur
02/19/2021, 8:30 AMSam
02/19/2021, 6:49 PMEkaterina Volodko [JB]
02/20/2021, 10:22 AMkevindmoore
02/20/2021, 6:19 PMAdam Brown
02/20/2021, 10:05 PMcommonMain
module. I add the dependency the way I assume it should work, but it doesn't seem to be included when I'm in source files in commonMain
any ideas what I could be doing wrong?Abhishek Dewan
02/22/2021, 4:24 AMAmritansh
02/22/2021, 6:49 PMcompileKotlinMetadata
task is failing in a KMM project when I run ./gradlew build
and I am getting following error. My app runs and build fine when I use IDE, this error only occurs when I use terminal to build or on my CI
DatabaseDispatcher.kt: (4, 27): Unresolved reference: newSingleThreadContext
DatabaseDispatcher.kt: (9, 36): Unresolved reference: newSingleThreadContext
DatabaseDispatcher.kt: (12, 47): Type mismatch: inferred type is Unit but CoroutineContext was expected
This is the class where it is failing
internal object DatabaseDispatcher : BackgroundDispatcher {
@ExperimentalCoroutinesApi
private val dbThread by lazy { newSingleThreadContext("database") }
@ExperimentalCoroutinesApi
override fun invoke(): CoroutineContext = dbThread
}
I am using these dependendies
kotlin = "1.4.30"
coroutines = "1.3.9-native-mt-2"
serialization = "1.0.1"
ktor = "1.4.3"
klock = "2.0.0"
benasherUUID = "0.2.3"
stately = "1.1.0"
junit = "4.12"
sqlDelight = "1.4.3"
This is how my build.gradle
looks likeCicero
02/22/2021, 7:09 PM* What went wrong:
An exception occurred applying plugin request [id: 'com.android.application']
> Failed to apply plugin 'com.android.internal.application'.
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `org.gradle.java.home` in `gradle.properties`.
Yes, so I actually changed my java system version:
11:~ ch$ $JAVA_HOME/bin/java -version
java version "11.0.10" 2021-01-19 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.10+8-LTS-162)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.10+8-LTS-162, mixed mode)
11:~ ch$
John Oberhauser
02/23/2021, 5:15 AMBen Lancaster
02/23/2021, 3:36 PMPrimary
, has a class called Timeline
in kotlin, then this is what I see in the iOS framework header:
__attribute__((swift_name("Timeline")))
@interface ServiceManagerTimeline : ServiceManagerBase
That’s good, it means in Swift I can use a class called Timeline
.
But if I have a class in the second module, called ServiceManager-common
(a dependency of Primary
), for example, the class ClientData
in kotlin, then this is what the header has:
__attribute__((swift_name("ServiceManager_commonClientData")))
@interface ServiceManagerServiceManager_commonClientData : ServiceManagerBase
Which means in Swift I have to use ServiceManager_commonClientData
class, instead of just ClientData
.
So, looks like that the generated framework always use the second module name as a prefix for all the classes in the second module.
I guess that KM does this because to avoid a potential name collision, given that there is no concept of namespace in Swift/ObjC. However, in my case, I am sure there is no name collision.
How can I deactivate or override this behavior?
Another option I see (I tested it and it is working) is modifying the final .h file and manually modify all the swift_name
tags. Not very nice, but works.
I also tried using baseName = ""
in the second module but no luck. Any ideas or suggestions welcome.
Thanks in advance.Guilherme Cordeiro
02/23/2021, 8:49 PMcommonMain
and commonTest
that I want to share (like frameworks, contracts, test utilities, etc)
2. Several other independently built modules, depending on the base module
What is the proper way to add the base module on the dependencies of the child modules?
Inside the sourceSets
block, for both commonMain
and commonTest
?
Can I access classes defined on the base module commonTest
inside a child module commonTest
?nikola
02/24/2021, 5:57 AM// -----------Groovy Old
task generateCinteropConfig(type: Exec) {
workingDir "${projectDir}"
commandLine 'sh', "${projectDir}/generate_cinterop_conf.sh"
}
gradle.taskGraph.beforeTask { Task task ->
if (task.project.name.toLowerCase().contains("ios")) {
"sh ${projectDir}/generate_cinterop_conf.sh ${projectDir}".execute().text
}
}
// ------------Kotlin DSL New
task<Exec>("generateCinteropConfig") {
workingDir = File("${projectDir}")
commandLine = listOf("sh", "${projectDir}/generate_cinterop_conf.sh")
}
tasks.register("generateCinteropConfig") {
doFirst() {
if (this.project.name.toLowerCase().contains("ios")) {
Runtime.getRuntime().exec("${projectDir}/generate_cinterop_conf.sh ${projectDir}")
}
}
}
Mariusz Tański
02/25/2021, 12:49 PMKoin Context configured. Please use startKoin or koinApplication DSL.
zalewski.se
02/25/2021, 6:19 PMnirazo
02/26/2021, 3:35 AMexecute
method from APP to get value.
The return values from UseCases are defined as Results, and puts it in Output of UseCase, and returns it to my APP.
Define of Results:
sealed class Results<out T, out S> {
class Success<out T>(val data: T) : Results<T, Nothing>()
class Failure<out S>(val cause: S) : Results<Nothing, S>()
}
Sample useCase and it’s IO:
interface SampleUseCaseInterface {
suspend fun execute(): sampleUseCaseIO.Output
}
class sampleUseCase() : SampleUseCaseInterface {
override suspend fun execute(): sampleUseCaseIO.Output =
sampleUseCaseIO.Output(Results.Success("success!"))
}
class sampleUseCaseIO {
data class Output(val results: Results<String, Error>)
}
Now, I want to mock the execute method of UseCase and return an arbitrary Output in order to write a Unit Test in an iOS app.
However, now the following error is displayed and it is not possible to create an arbitrary output.
Both data and error are required to be included in Results, and the required Output cannot be created.
Is there any way to avoid this?
Also, is it possible to realize a mechanism like Either on the iOS side with Kotlin/Native?Eirik Vale Aase
02/26/2021, 8:38 AMJeff Lockhart
02/27/2021, 7:07 PMapi("org.koin:koin-core:3.0.0-alpha-4")
and when I add Ktor implementation("io.ktor:ktor-client-core:1.5.2")
to my build.gradle.kts, all the Koin org.koin.*
imports start showing errors “Unresolved reference” in Android Studio 4.2-beta5. This is in a shared KMM module. My app compiles and runs without error. But why the IDE errors?Rob Murdock
02/28/2021, 8:57 PMMustafa Ozhan
03/01/2021, 9:56 AMKy
03/01/2021, 3:54 PMArchie
03/01/2021, 5:02 PMDaniel Burnhan
03/02/2021, 3:35 AMaleksey.tomin
03/02/2021, 8:09 AMkotlinx.coroutines.newSingleThreadContext
Build for the all targets done without error.
But if I call gradle compileKotlinMetadata
I see error
> Task :compileKotlinMetadata FAILED
e: <...>.kt: (28, 9): Unresolved reference: newSingleThreadContext
How can I fix it?Bill Mårtensson
03/02/2021, 10:09 AMrmyhal
03/02/2021, 12:39 PMios
and iosX64
configurations for running tests for commonTest
and don’t see android?. Project has two targets: android & ios. Thanks.
gradle config:
plugins {
kotlin("multiplatform")
id("com.android.library")
}
kotlin {
android()
ios {
binaries {
framework {
baseName = "shared"
}
}
}
val isiOSDevice = System.getenv("SDK_NAME").orEmpty().startsWith("iphoneos")
if (isiOSDevice) {
iosArm64("ios")
} else {
iosX64("ios")
}
sourceSets {
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
}
explicitApi()
}
android {
compileSdkVersion(30)
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdkVersion(23)
targetSdkVersion(30)
}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
}
}
bsimmons
03/02/2021, 4:55 PMrunBlocking
for unit tests in a MPP for native/ios? It looks like kotlinx-coroutines-core:1.4.1 doesn't include runBlocking
for native.Shawn Tucker
03/03/2021, 2:25 PM> Task :linkReleaseFrameworkIos
ld: framework not found FirebaseFirestore
It happened when I added gitlive/firebase dependency to my project.
I have a second project that have the same dependency and it works. Only difference is that in my other project I have cocoapods plugins.
What am I missing?Alex
03/03/2021, 5:39 PMMario Ruiz
03/03/2021, 5:43 PMGabriel Feo
03/04/2021, 12:14 AM