spierce7
11/24/2020, 9:26 PMkotlin("multiplatform")
projects depend on other gradle modules in the repo that are kotlin("jvm")
? I thought they could, but I’m seeing problemsShan
11/24/2020, 9:47 PMroot
|___core
|__src
|__commonMain
|__jvmMain //etc
|__build.gradle.kts
|___otherModule
|__src
|__commonMain
|__jvmMain //ec
|__ build.gradle.kts
|__settings.gradle.kts //root project name set here
|__gradle.properties
It's defaulting to core-jvm
/ core-metadata
etc. right now for the artifact ID, but i'd like all of the generated artifact IDs to be foo-jvm
/ foo-metadata
etc. I have been setting them all individually but feel like there might be a better way to just set that parameter once somewhere in the build script.Shan
11/24/2020, 11:33 PMmetadata
default artifact was removed in Kotlin 1.4.20, but I'm still seeing it when listing out the default publication names.
publishing {
publications.withType<MavenPublication>().names // [jvm, kotlinMultiplatform, metadata]
}
Should I just manually set it to not publish the metadata
artifact, or will it be ignored during the publish task?BollywoodVillain
11/25/2020, 12:54 PMkotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen
. It works fine on Android and gets the network data without issues. I created a brand new MPP project using Android Studio MPP template and added the Ktor network code from Ktor-sample/client-mpp repo. What could be the problem?
The complete project is on Github at: https://github.com/samkhawase/Kotlin_MPP_Demo.
I’m using ktor 1.4.2
, Kotlin 1.4
, Kotlin plugin 1.4.20-release-Studio4.1.1
, and KMM plugin 0.2.0-release-65-Studio4.1
.
Here’s a snapshot of my sourceSets
from build.gradle.kt
(:shared)
val ktor_version = "1.4.2"
sourceSets {
val commonMain by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.1")
implementation("io.ktor:ktor-client-core:$ktor_version")
implementation("io.ktor:ktor-client-serialization:$ktor_version")
}
}
val commonTest by getting {
dependencies {
//...
implementation("io.ktor:ktor-client-core:$ktor_version")
}
}
val androidMain by getting {
dependencies {
//...
implementation("io.ktor:ktor-client-android:$ktor_version")
implementation("io.ktor:ktor-client-serialization-jvm:$ktor_version")
}
}
val androidTest by getting {
dependencies {
//...
implementation("io.ktor:ktor-client-android:$ktor_version")
}
}
val iosMain by getting {
dependencies {
implementation("io.ktor:ktor-client-ios:$ktor_version")
implementation("io.ktor:ktor-client-serialization:$ktor_version")
}
}
val iosTest by getting {
dependencies {
implementation("io.ktor:ktor-client-ios:$ktor_version")
implementation("io.ktor:ktor-client-serialization:$ktor_version")
}
}
}
Here’s the failing Swift code
func getLocations() {
let apiService = ApiService()
apiService.about { (htmlString) in
print("🦋 htmlString:\n \(htmlString)")
}
}
struct ContentView: View {
var body: some View {
Text(greet()).onAppear {
print("isMainThread: \(Thread.isMainThread)")
getLocations()
}
}
}
Here’s the complete stacktrace from the iOS app.BollywoodVillain
11/25/2020, 12:54 PMisMainThread: true
Function doesn't have or inherit @Throws annotation and thus exception isn't propagated from Kotlin to Objective-C/Swift as NSError.
It is considered unexpected and unhandled instead. Program will be terminated.
Uncaught Kotlin exception: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen com.berlin.kmm_demo.shared.ApiService@2a37878
at 0 shared 0x0000000100c192dd kfun:kotlin.Throwable#<init>(kotlin.String?){} + 93 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/Throwable.kt:23:37)
at 1 shared 0x0000000100c121cb kfun:kotlin.Exception#<init>(kotlin.String?){} + 91 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/Exceptions.kt:23:44)
at 2 shared 0x0000000100c1238b kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 91 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/Exceptions.kt:34:44)
at 3 shared 0x0000000100c4793b kfun:kotlin.native.concurrent.InvalidMutabilityException#<init>(kotlin.String){} + 91 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/native/concurrent/Freezing.kt:22:60)
at 4 shared 0x0000000100c491f2 ThrowInvalidMutabilityException + 690 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt:92:11)
at 5 shared 0x0000000100d4136c MutationCheck + 108
at 6 shared 0x0000000100bb7ce7 kfun:com.berlin.kmm_demo.shared.ApiService#<init>(){} + 455
at 7 shared 0x0000000100bbc743 objc2kotlin + 163
at 8 iosApp 0x0000000100ae655f $sSo16SharedApiServiceCABycfC + 31
at 9 iosApp 0x0000000100ae6467 $s6iosApp12getLocationsyyF + 39 (/Users/skhawase/skunkworks/KMM_Demo/iosApp/iosApp/ContentView.swift:13:1)
at 10 iosApp 0x0000000100ae6eaa $s6iosApp11ContentViewV4bodyQrvgyycfU_ + 442 (/Users/skhawase/skunkworks/KMM_Demo/iosApp/iosApp/ContentView.swift:20:9)
at 11 SwiftUI 0x00007fff55f13d0c $sIeg_ytIegr_TR + 12
at 12 SwiftUI 0x00007fff55e22b01 $sIeg_ytIegr_TRTA + 17
at 13 SwiftUI 0x00007fff55f13d2c $sytIegr_Ieg_TR + 12
at 14 SwiftUI 0x00007fff55f13d0c $sIeg_ytIegr_TR + 12
at 15 SwiftUI 0x00007fff55e22b01 $sIeg_ytIegr_TRTA + 17
at 16 SwiftUI 0x00007fff55e22c09 $sIeg_ytIegr_TRTA.8 + 9
at 17 SwiftUI 0x00007fff5636e239 $s7SwiftUI16ViewRendererHostPAAE6render8interval17updateDisplayListySd_SbtFyyXEfU_ + 1657
at 18 SwiftUI 0x00007fff5636d2f7 $s7SwiftUI16ViewRendererHostPAAE6render8interval17updateDisplayListySd_SbtF + 343
at 19 SwiftUI 0x00007fff564d4e41 $s7SwiftUI14_UIHostingViewC14layoutSubviewsyyF + 241
at 20 SwiftUI 0x00007fff564d4e65 $s7SwiftUI14_UIHostingViewC14layoutSubviewsyyFTo + 21
at 21 UIKitCore 0x00007fff24bcd686 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2874
at 22 QuartzCore 0x00007fff27a5ae67 -[CALayer layoutSublayers] + 258
at 23 QuartzCore 0x00007fff27a61319 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 575
at 24 QuartzCore 0x00007fff27a6d071 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 65
at 25 QuartzCore 0x00007fff279ad158 _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 496
at 26 QuartzCore 0x00007fff279e3ef3 _ZN2CA11Transaction6commitEv + 783
at 27 UIKitCore 0x00007fff2468ab96 __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 81
at 28 CoreFoundation 0x00007fff203a85db __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
at 29 CoreFoundation 0x00007fff203a79ef __CFRunLoopDoBlocks + 434
Process finished with exit code 0
Amritansh
11/25/2020, 10:16 PMExecution failed for task ':shared:cinteropAFNetworkingIosArm64'.> Process 'command '/Applications/Android Studio 2.app/Contents/jre/jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
when I am adding a pod
cocoapods {
pod(name ="AFNetworking", version = "~> 4.0.1")
}
Anyone seen this before?František Hlinka
11/25/2020, 10:54 PMios()
target shortcut inside the kotlin {…}
block in build.gradle.kts
to create iOS targets for simulator and device and use the same iosMain
source set. However, the dependencies of the iOS target do not get resolved correctly in the IDE (specifically speaking, the Platform
object, or SQLDelight’s NativeSqliteDriver
).
If hierarchical project structure is disabled - e.g. gradle.properties
does not include
kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.native.enableDependencyPropagation=false
, then the project builds anyway even if the IDE can’t resolve the classes. If I add those two lines, the build fails too. This is happening on Kotlin 1.4.10 and 1.4.20.
Does anyone know what’s the problem or where should I open an issue? Thanks lots!Nikolay Kasyanov
11/26/2020, 3:54 PMcommonMain
when imported in files residing in jvmTest
. Doing ./gradlew clean
solves the problem (editor navigation starts using source code, red highlighting of imports goes away) until next build.
IDEA CE 2020.3 beta or 2020.2.4, Kotlin plugin 1.4.20.tjohnn
11/27/2020, 8:07 AMVinod Rai
11/28/2020, 6:30 AMimport org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins {
kotlin("multiplatform")
kotlin("plugin.serialization")
id("com.squareup.sqldelight")
}
kotlin {
val iosX64 = iosX64("ios")
val iosArm64 = iosArm64("iosArm64")
val iosArm32 = iosArm32("iosArm32")
val frameworkName = "EmtCore"
configure(listOf(iosX64, iosArm64, iosArm32)) {
binaries.framework {
baseName = frameworkName
}
}
sqldelight {
database("EmtCoreDatabase") {
packageName = "com.emt_core.db"
}
}
jvm("android")
sourceSets["commonMain"].dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-common")
implementation("io.ktor:ktor-client-core:1.4.1")
implementation("io.ktor:ktor-client-json:1.4.1")
implementation("com.russhwolf:multiplatform-settings-no-arg:0.6.1")
implementation("io.ktor:ktor-client-serialization:1.4.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9-native-mt-2")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.0.0-rc")
implementation("com.soywiz.korlibs.klock:klock:1.12.0")
implementation("io.ktor:ktor-client-logging:1.4.1")
implementation("com.squareup.sqldelight:runtime:1.4.3")
}
sourceSets["androidMain"].dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib")
implementation("io.ktor:ktor-client-android:1.4.1")
//implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.0.0-rc")
implementation("io.ktor:ktor-client-okhttp:1.4.1")
api("io.ktor:ktor-client-logging-jvm:1.4.1")
implementation("io.ktor:ktor-client-json-jvm:1.4.1")
implementation("io.ktor:ktor-client-serialization-jvm:1.4.1")
implementation("com.squareup.okhttp3:logging-interceptor:4.4.1")
implementation("com.squareup.sqldelight:android-driver:1.4.3")
}
sourceSets["iosMain"].dependencies {
implementation("io.ktor:ktor-client-ios:1.4.1")
//implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.0.0-rc")
implementation("io.ktor:ktor-client-json-native:1.3.2")
api("io.ktor:ktor-client-logging-native:1.3.2")
implementation("io.ktor:ktor-client-serialization-iosx64:1.4.1")
//implementation("io.ktor:ktor-client-serialization-iosarm64:1.4.0")
implementation("com.squareup.sqldelight:native-driver:1.4.3")
}
sourceSets["iosArm64Main"].dependencies {
implementation("io.ktor:ktor-client-ios:1.4.1")
//implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.0.0-rc")
implementation("io.ktor:ktor-client-json-native:1.3.2")
api("io.ktor:ktor-client-logging-native:1.3.2")
implementation("io.ktor:ktor-client-serialization-iosarm64:1.4.1")
//implementation("io.ktor:ktor-client-serialization-iosarm64:1.4.0")
implementation("com.squareup.sqldelight:native-driver:1.4.3")
}
sourceSets["iosArm32Main"].dependencies {
implementation("io.ktor:ktor-client-ios:1.4.1")
//implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.0.0-rc")
implementation("io.ktor:ktor-client-json-native:1.3.2")
api("io.ktor:ktor-client-logging-native:1.3.2")
implementation("io.ktor:ktor-client-serialization-iosarm32:1.4.1")
//implementation("io.ktor:ktor-client-serialization-iosarm64:1.4.0")
implementation("com.squareup.sqldelight:native-driver:1.4.3")
}
val debugFatFramework by tasks.creating(org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask::class) {
baseName = frameworkName
from(
iosArm32.binaries.getFramework("debug"),
iosArm64.binaries.getFramework("debug"),
iosX64.binaries.getFramework("debug")
)
destinationDir = buildDir.resolve("fat-framework/debug")
group = "Universal framework"
description = "Builds a debug universal (fat) framework"
}
val releaseFatFramework by tasks.creating(org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask::class) {
baseName = frameworkName
from(
iosArm32.binaries.getFramework("release"),
iosArm64.binaries.getFramework("release")
)
destinationDir = buildDir.resolve("fat-framework/release")
group = "Universal framework"
description = "Builds a release universal (fat) framework"
}
val zipDebugFatFramework by tasks.creating(Zip::class) {
dependsOn(debugFatFramework)
from(debugFatFramework)
// from("LICENSE.md")
}
val zipReleaseFatFramework by tasks.creating(Zip::class) {
dependsOn(releaseFatFramework)
from(releaseFatFramework)
//from("LICENSE.md")
}
}
Elyes Ben Salah
11/28/2020, 12:15 PMAzur Haljeta
11/28/2020, 1:47 PMframeworkName
specified in cocoapods{}
is ignored when building the .podspec
file via ./gradlew podspec
. It uses the name of the gradle project, which is also the default value. Any ideas?andylamax
11/28/2020, 6:59 PMjvmMain
contains kotlin code, while jvmTest
contains kotlin and java code? andy gradle sample?outadoc
11/28/2020, 9:05 PMlib-kemu
, and lib-chip8
(which depends on lib-kemu
locally).
Then two multiplatform modules, app-chip8-desktop
(Kotlin/JVM) and app-chip8-browser
(Kotlin/JS) which depend on lib-chip8
.
There’s a chance that I’m doing something wrong, but if that’s the case I cannot figure out what. And it’s getting really hard to progress with every line being errored out. 😞
The code is here: https://github.com/outadoc/kemu-chip8Kuba Petržílka
11/28/2020, 9:37 PMJide
11/29/2020, 10:00 AMCicero
11/30/2020, 1:50 PMnrobi
11/30/2020, 1:58 PMdispose()
and calling it from my ObservableObject
’s deinit
method (which represents my view’s state and essentially wraps my ViewModel while publishing the state to the view). Any thoughts if there is a better way?Javier
11/30/2020, 3:07 PMPhilip Dukhov
12/01/2020, 1:06 AMcinterop
tasks and run them, and it takes a lot of time. Any way to really cache them? As I understand those create kotlin headers for the libraries. Obviously I only need those to be run when dependencies or a config related to them changed. But now even when those tasks finished and I run build from Xcode
it doesn’t use the cache and rebuild it again and again.Frankablu
12/01/2020, 1:32 AMAnimesh Sahu
12/01/2020, 8:10 AMaleksey.tomin
12/01/2020, 8:16 AMCicero
12/01/2020, 10:35 AMDaniele B
12/01/2020, 2:48 PMTristan Blakers
12/01/2020, 11:35 PMsolidogen
12/01/2020, 11:37 PMJeff Tycz
12/02/2020, 12:18 AMPaul Woitaschek
12/02/2020, 8:16 AMNSDateComponents().hour
is a Long
in the iosX64Main source set and a Int
in the watchOsArm64Main
source set.
Is there any way around that?João Rodrigues
12/02/2020, 1:25 PM