Browse Source

Gradle plugin delete unavailable simulator (#2413)

* fix gradle plugin delete unavailable simulator
* apply suggestion to simpify usage of getSimctlListData()
pull/2414/head
dima.avdeev 2 years ago committed by GitHub
parent
commit
11fad5eca7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/registerSimulatorTasks.kt

15
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/registerSimulatorTasks.kt

@ -33,20 +33,21 @@ fun Project.registerSimulatorTasks(
)
val taskSimulatorDeleteUnavailable = tasks.composeIosTask<AbstractComposeIosTask>("iosSimulatorDeleteUnavailable$id") {
val condition = { device: DeviceData -> device.name == deviceName && device.state.contains("unavailable") }
onlyIf {
getSimctlListData().devices.map { it.value }.flatten().any(condition)
}
doLast {
val device = getSimctlListData().devices.map { it.value }.flatten().first(condition)
val device = getSimctlListData().devices.map { it.value }.flatten()
.firstOrNull { device: DeviceData ->
val xcode13Condition = device.state.contains("unavailable")
val xcode14Condition = device.isAvailable == false
device.name == deviceName && (xcode13Condition || xcode14Condition)
}
if (device != null) {
runExternalTool(
MacUtils.xcrun,
listOf("simctl", "delete", device.udid)
)
}
}
}
val taskCreateSimulator = tasks.composeIosTask<AbstractComposeIosTask>("iosSimulatorCreate$id") {
dependsOn(taskSimulatorDeleteUnavailable)

Loading…
Cancel
Save