Skip to content

Commit

Permalink
#762 fix support of custom build configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex009 committed Sep 22, 2024
1 parent f5bc03b commit c6a069e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 24 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ buildscript {
}
dependencies {
classpath "dev.icerock.moko:resources-generator:0.24.2"
classpath "dev.icerock.moko:resources-generator:0.24.3"
}
}
Expand All @@ -82,10 +82,10 @@ project build.gradle
apply plugin: "dev.icerock.mobile.multiplatform-resources"
dependencies {
commonMainApi("dev.icerock.moko:resources:0.24.2")
commonMainApi("dev.icerock.moko:resources-compose:0.24.2") // for compose multiplatform
commonMainApi("dev.icerock.moko:resources:0.24.3")
commonMainApi("dev.icerock.moko:resources-compose:0.24.3") // for compose multiplatform
commonTestImplementation("dev.icerock.moko:resources-test:0.24.2")
commonTestImplementation("dev.icerock.moko:resources-test:0.24.3")
}
multiplatformResources {
Expand Down Expand Up @@ -132,7 +132,7 @@ should [add `export` declarations](https://kotlinlang.org/docs/multiplatform-bui

```
framework {
export("dev.icerock.moko:resources:0.24.2")
export("dev.icerock.moko:resources:0.24.3")
export("dev.icerock.moko:graphics:0.9.0") // toUIColor here
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,24 +152,6 @@ internal fun registerCopyFrameworkResourcesToAppTask(
if (platform == null || archs == null || configuration == null) return

val kotlinMultiplatformExtension = project.extensions.getByType<KotlinMultiplatformExtension>()
val configMap: Map<String, NativeBuildType> = (kotlinMultiplatformExtension as? ExtensionAware)
?.extensions
?.findByType<CocoapodsExtension>()
?.xcodeConfigurationToNativeBuildType
?: emptyMap()

val configName: String = (configMap[configuration]?.name ?: configuration).lowercase()
// Map any configuration to standard with two types: "Debug/Release" builds
val clearConfigurationName: String = when {
configName.matches(".*debug.*".toRegex()) -> "debug"
configName.matches(".*release.*".toRegex()) -> "release"
else -> throw IllegalArgumentException(
"Invalid build configuration name: $configName. Please, update your configuration." +
"Configuration name should contains Debug or Release in name"
)
}
val requiredKonanTargets: List<String> =
AppleSdk.defineNativeTargets(platform, archs).map { it.name }
val frameworkNames: DomainObjectSet<String> =
project.objects.domainObjectSet(String::class.java)

Expand All @@ -185,10 +167,21 @@ internal fun registerCopyFrameworkResourcesToAppTask(
)

xcodeTask.configure {
val configMap: Map<String, NativeBuildType> =
(kotlinMultiplatformExtension as? ExtensionAware)
?.extensions
?.findByType<CocoapodsExtension>()
?.xcodeConfigurationToNativeBuildType
?: emptyMap()

val configName: String = (configMap[configuration]?.name ?: configuration).lowercase()
val requiredKonanTargets: List<String> =
AppleSdk.defineNativeTargets(platform, archs).map { it.name }

it.dependsOn(
project.tasks.withType<CopyFrameworkResourcesToAppTask>().matching { copyTask ->
val isCorrectConfiguration: Boolean =
copyTask.configuration.lowercase() == clearConfigurationName
copyTask.configuration.lowercase() == configName
val isCorrectFrameworkPrefix: Boolean =
copyTask.frameworkPrefix == frameworkPrefix
val isCorrectKonanTarget: Boolean =
Expand Down

0 comments on commit c6a069e

Please sign in to comment.