spierce7
11/03/2021, 2:07 PMpublishAllPublicationsToArtifactoryRepository UP-TO-DATE
mbonnin
11/03/2021, 2:22 PMEtienne
11/03/2021, 4:15 PMMarcello Galhardo
11/03/2021, 6:33 PMjimn
11/04/2021, 9:37 AMlonto
11/04/2021, 12:44 PMMetalEngine.def
file :
language = Objective-C
modules = MetalEngine
package = MetalEngine
And this is the gradle build script from shared module :
iosTarget("ios") {
binaries {
framework {
baseName = "shared"
}
}
compilations.getByName("main") {
val MetalEngine by cinterops.creating {
defFile("src/nativeInterop/cinterop/MetalEngine.def")
compilerOpts("-framework", "MetalEngine", "-F/shared/src/MetalEngine.xcframework")
}
}
binaries.all {
linkerOpts("-framework", "MetalEngine", "-F/shared/src/MetalEngine.xcframework")
}
}
Im getting fatal error: module 'MetalEngine' not found
error. Am I missing any config step?Rak
11/04/2021, 3:34 PMHadji Musaev
11/04/2021, 4:04 PMnoCompress
option. I’m trying to load a tensorflow lite model from assets in tests following this standard approach: https://www.tensorflow.org/lite/inference_with_metadata/lite_support
Here’s a minimal version of the test that fails:
@RunWith(RobolectricTestRunner::class)
class MyTest {
lateinit var interpreter: Interpreter
@Before
fun setUp() {
val context = InstrumentationRegistry.getInstrumentation().targetContext
val tfliteModel = FileUtil.loadMappedFile(context, "model.tflite")
interpreter = Interpreter(tfliteModel)
}
When I run it, it outputs java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
. However, I specified this in my gradle.build inside the android{}
entry:
aaptOptions {
noCompress("tflite")
}
What could I be doing wrong?
P.S. I apologise if this problem is not KMP specific 😅libliboom
11/05/2021, 2:16 AMorg.jetbrains.kotlinx
or io.ktor
.Rak
11/05/2021, 9:19 AMStefan Oltmann
11/05/2021, 12:56 PMUncaught Kotlin exception: kotlin.Throwable: The process was terminated due to the unhandled exception thrown in the coroutine [StandaloneCoroutine{Cancelling}@2929dd8, MainDispatcher]: mutation attempt of frozen kotlin.collections.HashMap@3b0368
if I do this:
val newPhotoSourceSyncInfo = mutableMapOf<PhotoSource, SyncInfo>()
newPhotoSourceSyncInfo.putAll(oldState.photoSourceSyncInfo)
newPhotoSourceSyncInfo[photoSource] = syncInfo
return oldState.copy(
photoSourceSyncInfo = newPhotoSourceSyncInfo
)
But I can do this without any problem:
val newPhotoSources = mutableListOf<PhotoSource>()
newPhotoSources.addAll(oldState.photoSources)
newPhotoSources.add(
PhotoSource(
id = 1
)
)
return oldState.copy(
photoSources = newPhotoSources,
)
Why is that for a HashMap different and how can I do it to please the memory model?Paul Davies
11/05/2021, 3:30 PMval iosTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
::iosArm64
else
::iosX64
iosTarget("ios") {}
to the newer shortcut (which we need to use on our Apple M1 machines)
ios()
Since I’ve done this, I’m getting red import errors in Android Studio (Arctic Fox | 2020.3.1 Patch 3, KMM Plugin ) when trying to import iOS platform frameworks.
Have I missed something in configuration? 1.5.31 has the same issue fwiwmbonnin
11/08/2021, 11:24 AM// MyClass is platform-specific
expect class MyClass(
param1: Param1,
param2: Param2,
param3: Param3
) {
// Builder is the same for all platforms
class Builder {
var param1: Param1? = null
// ...
fun build(): MyClass {
return MyClass(
param1 = param1 ?: defaultParam1,
// ...
)
}
}
}
Ivan Đorđević
11/08/2021, 12:10 PMcommonTest
sourceset from one project module as a dependency in commonTest
sourceset from another project module?Stefan Oltmann
11/08/2021, 1:57 PMprivate val scope = CoroutineScope(Dispatchers.Default)
class PhotoSyncService {
private var jobMap: MutableMap<PhotoSource, Job> = mutableMapOf()
fun sync(photoSource: PhotoSource, updateSyncInfo: (SyncInfo) -> Unit) {
val existingJob = jobMap[photoSource]
if (existingJob != null && existingJob.isActive)
return
val job = scope.launch {
try {
updateSyncInfo(
SyncInfo(
log = "Starting...",
status = SyncStatus.SYNCING
)
)
delay(2500)
updateSyncInfo(
SyncInfo(
log = "Sync done.",
status = SyncStatus.SYNCED
)
)
} catch (ex: CancellationException) {
updateSyncInfo(
SyncInfo(
log = "Sync canceled.",
status = SyncStatus.ERROR
)
)
}
}
jobMap[photoSource] = job
}
fun cancelSync(photoSource: PhotoSource) {
val job = jobMap[photoSource]
job?.let {
job.cancel()
jobMap.remove(photoSource)
}
}
}
And I got a PhotoStore
class that uses this service like that:
private fun forceSync(
oldState: PhotoState,
photoSource: PhotoSource
): PhotoState {
photoSyncService.sync(photoSource) { syncInfo ->
/*
* This update comes from an background coroutine.
* So we need to bring it back to the main thread.
*/
launch(Dispatchers.Main) {
this@PhotoStore.dispatch(PhotoAction.SyncInfoUpdate(photoSource, syncInfo))
}
}
return oldState
}
The forceSync()
is called on the main thread.
PhotoSyncService
is also initialized on the main thread.
As soon as my updateSyncInfo
lambda is called in my launch
block it freezes the PhotoSyncService
& PhotoStore
... The line jobMap[photoSource] = job
gives me a InvalidMutabilityException
.
I first thought there were other reasons, but after tracking everything down I know that it must be the lambda call-
But why? Because of the call to "this"?Daniele Andreoli
11/08/2021, 2:44 PMKareem Radwan
11/08/2021, 3:00 PMpublishToMavenLocal
task to use it on other project
when I add my library on new kotlin multipatform project only jvm
target was added no js
or ios
Jishin Dev [JD]
11/08/2021, 4:17 PMandroidMain
but how do I achieve this with SwiftUI for the iOS targets?jivimberg
11/08/2021, 5:36 PM:compileTestKotlinJs
.
What I see it doing is:
1. It says it has to perform non-incremental compilation. Non-incremental compilation will be performed: UNKNOWN_CHANGES_IN_GRADLE_INPUTS
2. It clears the output folders. Including build/classes/kotlin/js
where the JS sources should be compiled
3. It complains it can’t find build/classes/kotlin/js/main
🤦Antonio Acuña Prieto
11/08/2021, 7:07 PMLukasz Kalnik
11/09/2021, 5:06 PMshared
:
CommonModule.kt:
val commonModule = module {
single<HttpClient> { TmdbApi.createHttpClient() }
single<TmdbApi> { TmdbApi(client = get()) }
}
fun initKoin() = startKoin {
modules(CommonModule.module)
}
In the Android app I can inject dependencies very easily:
val tmdbApi: TmdbApi by inject()
In the iOS AppDelegate I call CommonModuleKt.doInitKoin()
How can I inject the dependencies in the iOS ContentView
?csaba8472
11/09/2021, 6:33 PMjean
11/10/2021, 7:52 AMpublishSingleVariant("release")
like stated in the description. What’s the status on this @louiscad? Are we still supposed to use the fallback workaround?Osman Saral
11/10/2021, 10:26 AMNo tasks available
error from Android Studio. Why does it happen?Rak
11/10/2021, 11:20 AMIvan Đorđević
11/10/2021, 12:28 PMiosMain
) and interact with it from Kotlin code?Bastian
11/10/2021, 5:30 PMKotlinByteArray
from within my iOS app.
For that, I use KotlinByteArray.init(size:init:)
let hundredMB = 1024 * 1024 * 100
let bytes = KotlinByteArray(size: hundredMB) { _ in 5 }
For some reason, this takes about 1:20 minutes to complete and about 7 GB of RAM (iPhone Simulator).
This made me curious. Does anyone know why?
I already found the note that the init function is being called for each and every entry of the Array.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/-init-.html
But why so much memory usage? Also, NSData achieves the same in mere seconds.Angad
11/11/2021, 9:11 AMkotlin.native.internal.GC.collect()
when screens are getting closed) the leaks exist. I'm sharing screenshots for some of the memory leaks. Has anyone else seen these kind of leaks before?Matheus Finatti
11/11/2021, 3:30 PMsuspend
function in Swift
I have an interface, e.g.:
interface Loader {
suspend fun fetch()
}
which I implement in Android and in iOS.
The iOS version looks like this:
public class RemoteFeatureLoader : Loader {
public func fetch(completionHandler: @escaping (KotlinUnit?, Error?) -> Void) {
doAsyncStuff { [weak self] in
completionHandler(KotlinUnit(), nil)
}
}
}
And the caller in the shared code looks like this
class CommonLoader() {
override suspend fun fetch() {
localFeatureLoader.fetch()
remoteFeatureLoader.fetch()
}
}
and finally, the CommonLoader.fetch()
is being called from a view model which is also shared
class CommonViewModel(
private val scope: CoroutineScope,
private val uiContext: CoroutineContext,
) : ViewModel {
override fun startup() {
scope.launch(context = uiContext) {
loader.fetch()
}
}
}
Basically, the Android version works like a charm, but the iOS version hangs at loader.fetch()
If I add a log after remoteFeatureLoader.fetch()
it is printed just fine, but the function never returns/resumes from its suspended state.
Does anyone have any clue what could be going on? I appreciate any help! Thank you!fvink
11/11/2021, 4:41 PMAndroid Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
😅