Usman Akhmedov
11/13/2023, 2:33 PMJeff Lockhart
11/13/2023, 2:44 PMUsman Akhmedov
11/13/2023, 3:05 PMFrancis Mariano
11/13/2023, 3:08 PMJeff Lockhart
11/13/2023, 3:40 PMFrancis Mariano
11/13/2023, 3:46 PMUsman Akhmedov
11/13/2023, 3:48 PMJeff Lockhart
11/13/2023, 3:51 PMUsman Akhmedov
11/13/2023, 3:57 PMJeff Lockhart
11/13/2023, 6:07 PMUsman Akhmedov
11/13/2023, 6:08 PMJeff Lockhart
11/13/2023, 6:09 PMcopyNativeResources
to take an optional module as well as the source set name. Then use that module name, if present, to point the from("src/$sourceSet/resources")
path to the source set within the module. Something like from("../$moduleName/src/$sourceSet/resources")
.What do you mean „root“?The module that depends on the other modules. The module that is building the shared iOS framework.
Usman Akhmedov
11/13/2023, 6:10 PMJeff Lockhart
11/13/2023, 6:11 PMcopyNativeResources
should only be done in the root module that is building the iOS framework. And it will need to copy the resources from all source sets and modules that you need to get the resources from.Usman Akhmedov
11/13/2023, 6:13 PMcopyNativeResources("commonMain")
fun copyNativeResources(sourceSet: String) {
if (sourceSet.isEmpty()) throw IllegalStateException("Valid sourceSet required")
val prefix = "copy${sourceSet.capitalize()}Resources"
tasks.withType<KotlinNativeLink> {
val firstIndex = name.indexOfFirst { it.isUpperCase() }
val taskName = "$prefix${name.substring(firstIndex)}"
dependsOn(
tasks.register<Copy>(taskName) {
from("../core/design/src/$sourceSet/resources")
when (outputKind) {
CompilerOutputKind.FRAMEWORK -> into(outputFile.get())
CompilerOutputKind.PROGRAM -> into(destinationDirectory.get())
else -> throw IllegalStateException("Unhandled binary outputKind: $outputKind")
}
}
)
}
tasks.withType<FatFrameworkTask> {
if (destinationDir.path.contains("Temp")) return@withType
val firstIndex = name.indexOfFirst { it.isUpperCase() }
val taskName = "$prefix${name.substring(firstIndex)}"
dependsOn(
tasks.register<Copy>(taskName) {
from("../core/design/src/$sourceSet/resources")
into(fatFramework)
}
)
}
}
Jeff Lockhart
11/13/2023, 6:16 PMcore/design/src/commonMain/resources
the only resource directory you need to copy to the framework?Usman Akhmedov
11/13/2023, 6:16 PMJeff Lockhart
11/13/2023, 6:17 PMUsman Akhmedov
11/13/2023, 6:19 PMJeff Lockhart
11/13/2023, 6:43 PM