Hey folks, is anyone else seeing this? While upgr...
# multiplatform
n
Hey folks, is anyone else seeing this? While upgrading our project to 1.3.71, I also switched to the recommended syntax of defining iOS source sets, replacing this:
Copy code
iosX64Main { ...dependencies... }
iosArm64Main {
    dependsOn iosX64Main
}
with this:
Copy code
ios {
    iosArm64Main.dependsOn it
    iosX64Main.dependsOn it

    ...dependencies...
}
moving iOS-only source files from
iosX64Main
to
ios
folder accordingly. Now all imports starting with
platform.
are highlighted red in the IDE all the time, builds fine though. Is this a known issue?
For the record, IDE plugin version is
1.3.71-release-IJ2019.3-1
a
Hello! Can you show a bit more on your project’s current structure? IIRC,
ios{…}
shortcut should create an
src/iosMain/kotlin
folders, not an
/ios
one.
n
having the same experience with
iosMain
folder on another project
sure, I’ll try
a
I’m also confused a bit with this
.dependsOn
constructions, the purpose of the shortcut was to get rid of this.
n
@Artyom Degtyarev [JB] oh yes, I might’ve misinterpreted the docs. Is there any reference `build.gradle`/`build.gradle.kts` example to have a look at?
I’m looking at https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#target-shortcuts and can’t figure out how to replace the
sourceSets.iosMain
example with the new
ios
shortcut.
a
I’m not informed on any sample scripts, maybe some of them can be found across the community. We had some problems with this feature(see this issue for example). To use the shortcut, just change your target’s declaration with the
ios{...}
, with saving all contents of the original
ios<Arm | X>64
block. The only thing the shortcut does is adding both targets internally, making their source sets depending on the new
iosMain
and that’s all. So, there is no need to specify them explicitly as you’ve done.
n
I tried looking at open source examples but couldn’t yet find any using the new shortcut.
Thanks, I’ll check out the issue and try what you’ve suggested.
turns out
kotlin.mpp.enableGranularSourceSetsMetadata=true
is a must for it to work
👍 1
o
@Nikolay Kasyanov Did you find a solution? enableGranularSourceSetsMetadata didn’t help me:(
a
hi, @Olenyov Kirill! Are you also facing highlighting issues when using
ios
target shortcuts?
o
Yeah, all import platform.* are red. But building is fine..
n
aside of
kotlin.mpp.enableGranularSourceSetsMetadata=true
I changed the structure like this:
Copy code
kotlin {
    ios()

    sourceSets {
        ...
        iosMain {
            // no explicit dependsOn calls needed

            
        }
        ...
    }
}
@Olenyov Kirill have you restarted IDEA after adding
kotlin.mpp.enableGranularSourceSetsMetadata=true
to
gradle.properties
?
not sure why reimporting/reloading project wasn’t helping
(restarting might be a nuclear option, closing and reopening the project might do too)
o
After adding kotlin.mpp.enableGranularSourceSetsMetadata=true I have a problems not only with platform dependings. But also with kotlinx.* Now all are red)) And I see in log: There is a library attached to the project that was compiled with a newer Kotlin/Native compiler and can’t be read in IDE: “common.klib” at $project/common/build/classes/kotlin/iosX64/main/common.klib Please edit Gradle buildfile(s) to use Kotlin Gradle plugin version 1.3.61. Then rebuild the project and re-import it in IDE. I have AS 3.6.2. May it be the root cause?
a
Are your project Kotlin version and an IDE’s Kotlin plugin version synchronized?
o
How to check IDE’s plugin version?
a
Tools > Kotlin > Configure Kotlin Plugin Updates
IIRC.
o
I see a newer version for AS. I’ll to install..
Fixed!
🎉 3
n
@Artyom Degtyarev [JB] thanks for your help!
o
Yeah, thanks!
@Artyom Degtyarev [JB] Found another issue. With enableGranularSourceSetsMetadata=true all my “actual” methods in androidMain are red now:(
a
Seems related to (https://youtrack.jetbrains.com/issue/KT-33809). There is a workaround in the discussion, please give it a try.
o
Yeah, it works. Thanks!