https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
f

František Hlinka

11/25/2020, 10:54 PM
Hey guys! We’re using the
ios()
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
Copy code
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!
r

Rhony

11/26/2020, 1:50 AM
For your sqldelight, you can put this code inside kotlin braces
Copy code
kotlin {
    val onPhone = System.getenv("SDK_NAME")?.startsWith("iphoneos") ?: false
    if (onPhone) iosArm64("ios")
    else iosX64("ios")
}
for more info here Adding Sqldelight on moko or here Unresolved reference: com.squareup.sqldelight.drivers.native.NativeSqliteDriver
f

František Hlinka

11/26/2020, 10:56 AM
Hmm, this won’t work because I need both of the targets to be added, not only one depending on the environment - this causes one of the targets to be unresolved, so Gradle sync fails. What is interesting is that according to the links, this should be related to hierarchical project structure, but the project builds (even though the IDE doesn’t resolve it) if hierarchical structure is disabled. Thanks anyway!
👍 1
a

Artyom Degtyarev [JB]

11/26/2020, 11:03 AM
Hello, @František Hlinka, I’ve seen similar problem here: https://youtrack.jetbrains.com/issue/KT-43516
f

František Hlinka

11/26/2020, 11:21 AM
thanks, @Artyom Degtyarev [JB] ! But the solution is similar as I posted here - if I understand it correctly, it disables hierarchical project structure, which results in the project building correctly but the IDE still doesn’t resolve classes.
a

Artyom Degtyarev [JB]

11/26/2020, 11:25 AM
Yes, I’m waiting for the response from the dev team about other negative effects of
enableGranularSourceSetsMetadata
disabled. AFAIK it is about highlighting only, but I’ll be more confident as soon as someone will confirm.
f

František Hlinka

11/26/2020, 11:43 AM
alright, thanks for help! if you let me know when you’ve learned more, I’ll be glad 🙂