spierce7
11/18/2021, 3:44 PMFlow
. I’m performing a blocking call on a coroutine thread (Using Dispatchers.IO), and because of that, even though the Collecting flow is finished, the cancellation logic (killing a process in this case), doesn’t happen for a good while after:
try {
while (currentCoroutineContext().isActive && process.isAlive) {
val line = bufferedProcessSource.readUtf8Line() ?: break
emit(line)
}
} catch (e: CancellationException) {
throw e
} finally {
if (process.isAlive) {
println("C$id - Destroying Process")
process.destroy()
}
}
Andrew O Hart
11/18/2021, 6:17 PM//get an instance of the File Manager
NSFileManager *fileManager = [NSFileManager defaultManager];
//we'll list file in the temporary directory
NSString * strPath = NSTemporaryDirectory();
//we'll need NSURL for the File Manager
NSURL *tempDirURL = [NSURL fileURLWithPath:strPath];
//An array of NSURL object representing the path to the file
//using the flag NSDirectoryEnumerationSkipsHiddenFiles to skip hidden files
NSArray *directoryList = [fileManager contentsOfDirectoryAtURL:tempDirURL
includingPropertiesForKeys:nil
options:NSDirectoryEnumerationSkipsHiddenFiles error:nil];
How can that be written in Kotlin?
I think I need to do import platform.Foundation.NSFileManager right?
I'm not sure exactly how I can find a .db file though. Or use these classes / methods.
Is there a way to see method names etc in the IDE? Right now it seems to import but its red and I can't see methods etc.
Any tips would be greatBart Whiteley
11/18/2021, 6:33 PM./gradlew assembleXCFramework
, the resulting XCFramework is missing the ios-arm64-simulator
slice. What am I doing wrong?Paulo Cereda
11/19/2021, 10:53 AMAndrew O Hart
11/19/2021, 2:21 PMSebastian Sellmair [JB]
11/19/2021, 2:45 PMMihai Voicescu
11/19/2021, 5:41 PMpluginManagement {
resolutionStrategy {
eachPlugin {
if (requested.id.namespace == "com.android") {
useModule("com.android.tools.build:gradle:4.1.2")
}
}
}
plugins {
id("com.android.library") apply false
kotlin("multiplatform") version kotlin_version apply false
kotlin("plugin.serialization") version kotlin_version apply false
subproject `build.gradle.kts`:
plugins {
kotlin("multiplatform")
kotlin("plugin.serialization")
id("com.android.library")
}
kotlin {
js {browser {
}}}
Short trace:
org.gradle.internal.exceptions.LocationAwareException: Build file '/Users/mihaivo/IdeaProjects/gaia/gaia-phone-client/build.gradle.kts' line: 26
Caused by: org.gradle.api.reflect.ObjectInstantiationException: Could not create an instance of type org.jetbrains.kotlin.gradle.targets.js.subtargets.KotlinBrowserJs.
at org.gradle.internal.instantiation.generator.DependencyInjectingInstantiator.doCreate(DependencyInjectingInstantiator.java:69)
at org.gradle.internal.instantiation.generator.DependencyInjectingInstantiator.newInstance(DependencyInjectingInstantiator.java:55)
at org.gradle.api.internal.model.DefaultObjectFactory.newInstance(DefaultObjectFactory.java:85)
Caused by: java.lang.IllegalStateException: The Kotlin Gradle plugin was loaded multiple times in different subprojects, which is not supported and may break the build.
This might happen in subprojects that apply the Kotlin plugins with the Gradle 'plugins { ... }' DSL if they specify explicit versions, even if the versions are equal.
Please add the Kotlin plugin to the common parent project or the root project, then remove the versions in the subprojects.
If the parent project does not need the plugin, add 'apply false' to the plugin line.
See: <https://docs.gradle.org/current/userguide/plugins.html#sec:subprojects_plugins_dsl>
at org.jetbrains.kotlin.gradle.targets.js.MultiplePluginDeclarationDetector.detect(MultiplePluginDeclarationDetector.kt:26)
at org.jetbrains.kotlin.gradle.targets.js.MultiplePluginDeclarationDetector$Companion.detect(MultiplePluginDeclarationDetector.kt:52)
at org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin.apply(NodeJsRootPlugin.kt:23)
Ruben Quadros
11/20/2021, 3:11 PM1.6.0
and the project is not syncing anymore. I also get the same error when trying to create a new KMM project. I have tried pod install
in iosApp
and then sync but still the same error. I have also tried invalidate caches and restart (AS). Stack trace in the thread.jean
11/20/2021, 3:14 PMasync
is not resolved from my common package but CompletableDeferred
is. Does kmm prevent usage of async
keyword somehow? Or is it because I’m using the native-mt version of kotlinx.coroutine?Nacho Ruiz Martin
11/20/2021, 7:19 PMursus
11/21/2021, 2:22 PMMatti MK
11/22/2021, 8:52 AM12.5.1
, wondering about updating to 13, I guess it should be safe already. Did anyone face issues on updating the version?MarkRS
11/22/2021, 9:33 AMjean
11/22/2021, 12:26 PMexpect fun weekOfYear(time: String): Int
// android
actual fun weekOfYear(time: String): Int {
val calendar: Calendar = Calendar.getInstance(TimeZone.getDefault())
val sdf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.getDefault())
calendar.time = sdf.parse(time)!!
return calendar.get(Calendar.WEEK_OF_YEAR)
}
// ios
actual fun weekOfYear(time: String): Int {
val dateFormatter = NSDateFormatter().apply {
setDateStyle(none)
setTimeStyle(none)
setTimeZone(NSTimeZone.defaultTimeZone)
setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
}
val date = dateFormatter.dateFromString(time)
date ?: return 0
val calendar = NSCalendar.currentCalendar
val components = calendar.components(NSCalendarUnitWeekOfYear, date)
return components.weekOfYear.toInt()
}
But it gives me different results out of the same date "2021-01-01T22:00:00.000+0000"
This tests fails on iOS
@Test
fun `week of year should be 1`() {
val weekOfYear = weekOfYear("2021-01-01T22:00:00.000+0000")
assertEquals(1, weekOfYear)
}
it return 53
on iOS. Any advice on how to fix this?Brian Donovan
11/22/2021, 7:24 PMMartin Rajniak
11/22/2021, 8:11 PMthe linked and embedded framework is missing one or more architectures required by this target: arm64
I am using M1 Mac and trying to run it with simulator so that will be an issue (since we see no issue on other architectures).
The weird part is that the template task mentions arm64 architecture:
val packForXcode by tasks.creating(Sync::class) {
group = "build"
val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
val sdkName = System.getenv("SDK_NAME") ?: "iphonesimulator"
val targetName = "ios" + if (sdkName.startsWith("iphoneos")) "Arm64" else "X64"
val framework =
kotlin.targets.getByName<KotlinNativeTarget>(targetName).binaries.getFramework(mode)
inputs.property("mode", mode)
dependsOn(framework.linkTask)
val targetDir = File(buildDir, "xcode-frameworks")
from({ framework.outputDirectory })
into(targetDir)
}
When I try KMM project I don't have this problem (but then the library is linked, so it is a different scenario).
Any ideas or experience with this?Peter Hsu
11/23/2021, 6:02 AMandroid.util.*
and java.util.*
in commonMain?dsavvinov
11/23/2021, 12:46 PMLena Stepanova
11/23/2021, 2:04 PMNicklas Jensen
11/23/2021, 2:41 PM@Mock
and assigning it to the value of a call to the <T> mock(KClass<T>)
function:
class GitHubServiceTests {
@Mock
val api = mock(GitHubAPI::class)
}
Please see the README for instructions on how to get started using Mockative today. We would love to hear your feedback on the framework.Martin Rajniak
11/23/2021, 4:42 PMLaurence Muller
11/23/2021, 10:28 PMval iosMain by getting
is now replaced by val iosMain by creating
and using
{
dependsOn(commonMain)
iosX64Main.dependsOn(this)
iosArm64Main.dependsOn(this)
//iosSimulatorArm64Main.dependsOn(this)
}
With iosX64Main
and iosArm64Main
being split up to its own val
.
Does this mean I should be adding the dependencies for both (basically just copy them over in both sections)? For some reason, Android studio doesnt want to resolve the correct driver (for sqldelight in my case). See screenshots in the 🧵 .Pavel Repkin
11/24/2021, 1:59 PMWilliam Reed
11/24/2021, 5:14 PMScott Kruse
11/24/2021, 7:16 PMcommonMain
source set from the consumer of the corresponding android target AAR? Right now my project has a couple public composables defined in commonMain
, but they're not visible to my android project. The AAR is resolved via mavenLocal
at the momentPiotr Prus
11/24/2021, 10:02 PMEmil Kantis
11/24/2021, 10:51 PMorg.jetbrains:annotations
from commonMain? I can’t seem to get it to work.. Assuming the dependency is only available for JVM, is there any way to add annotations for jvm target? 🤔Scott Kruse
11/25/2021, 4:27 AMelect
11/25/2021, 9:44 AMassert()
from kotlin common stdlib for testing?xxfast
11/25/2021, 12:34 PMpackForXCode
task to embedAndSignAppleFrameworkForXcode
. In step 4, setting linker flags where we have to do $(inherited) -framework shared
how would we link more than one library here?