https://kotlinlang.org logo
Title
m

Maurice Wingbermuhle

11/02/2020, 10:10 AM
Hi All, Does anyone know if there is documentation about the wrapping of Foundation and other iOS system libraries in Kotlin? We currently develop without code-completion, and no reference, so purely trial and error for getting the iOS part of our actual implementation. Any documentation or github page where we can lookup stuff is appreciated.
s

Sam

11/02/2020, 1:21 PM
If you’re developing on a Mac using IntelliJ and don’t have completions, there is something wrong with your setup.
m

Maurice Wingbermuhle

11/02/2020, 1:36 PM
I am, and I see the same red
platform
imports as Darran Kelinske has posted last tuesday
l

louiscad

11/03/2020, 8:54 AM
If you use the KMM plugin in Android Studio 4.1+ and try with a new project/module created with the template, you should get autocompletion on a Mac.
m

Maurice Wingbermuhle

11/03/2020, 8:58 AM
Yes, we can reproduce that. I don't know what the difference is yet, we have a fairly complicated setup. I will have to dive into this sometime
d

dazza5000

11/03/2020, 1:49 PM
I still have red imports for platform components, but it will build a framework successfully.
I have tried all of the various flags and haven't found success. Still working on it today. Will report back.
t

Tijl

11/04/2020, 9:06 AM
most reliable method is no HMPP, with only a single iOS target declared.
m

Maurice Wingbermuhle

11/05/2020, 1:08 PM
I've managed to fix in my project - the trick is to not use the HMPP for iOS. So instead of this:
configure([iosX64Main, iosArm64Main]) {
      dependsOn iosMain
}
use this:
iosArm64Main {
    dependencies {
    }
    kotlin.srcDir("${projectDir}/src/iosMain/kotlin")
}

iosX64Main {
    dependencies {
    }
    kotlin.srcDir("${projectDir}/src/iosMain/kotlin")
}
If you have any dependencies in
iosMain
you need to duplicate them to the 2 specific variant.
iosMain
needs to still exist, but is allowed to be empty. This restores my compiler setup for native platform code, including code completion. I am still using HMPP for JVM targets, and that still works without any issue.
👍 1
a

Artyom Degtyarev [JB]

11/05/2020, 1:20 PM
Could you please share the project at kotl.in/issue? At least the Gradle script and environment description.
m

Maurice Wingbermuhle

11/05/2020, 2:06 PM
@Artyom Degtyarev [JB] Issue has been created, with minimal project, broken and fixed: https://youtrack.jetbrains.com/issue/KT-43192
👀 1
:thank-you: 3
d

dazza5000

11/06/2020, 1:41 AM
what is hmpp
why did you have to do this - it seems like that should be automatic by the nature of kotlin mp
iosMain {
    dependsOn commonMain
}
a

Artyom Degtyarev [JB]

11/06/2020, 9:12 AM
Hello, @dazza5000! HMPP is an abbreviation for hierarchical multiplatform programming. In fact, this is about projects structured as here, not a big difference from an ordinary Kotlin Multiplatform. About explicit dependency on commonMain. As described in the documentation,
dependsOn
relation provide several features, and some of them might not be useful for every new source set. For example, if you want to make a project with hierarchical structure and source sets tree depth more >= 4(e.g.
commonMain
->
nativeMain
for all Native targets ->
appleMain
for Apple subset of Native targets ->
iosX64Main
), I’m not sure making all intermediate source sets depend on the common one is a good idea.