diff --git a/aws-crt-kotlin/build.gradle.kts b/aws-crt-kotlin/build.gradle.kts index 05dc7dc5..dff0943a 100644 --- a/aws-crt-kotlin/build.gradle.kts +++ b/aws-crt-kotlin/build.gradle.kts @@ -11,6 +11,8 @@ import aws.sdk.kotlin.gradle.kmp.IDEA_ACTIVE import aws.sdk.kotlin.gradle.kmp.configureKmpTargets import aws.sdk.kotlin.gradle.util.typedProp import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget +import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest +import org.jetbrains.kotlin.konan.target.HostManager plugins { alias(libs.plugins.kotlin.multiplatform) @@ -167,6 +169,45 @@ kotlin { } } +// disable "standalone" mode in simulator tests since it causes TLS issues. this means we need to manage the simulator +// ourselves (booting / shutting down). FIXME: https://youtrack.jetbrains.com/issue/KT-38317 +kotlin { + val simulatorDeviceName = project.findProperty("iosSimulatorDevice") as? String ?: "iPhone 15" + + val xcrun = "/usr/bin/xcrun" + + tasks.register("bootIosSimulatorDevice") { + commandLine(xcrun, "simctl", "boot", simulatorDeviceName) + + doLast { + val result = executionResult.get() + val code = result.exitValue + if (code != 148 && code != 149) { // ignore "simulator already running" errors + result.assertNormalExitValue() + } + } + } + + tasks.register("shutdownIosSimulatorDevice") { + mustRunAfter(tasks.withType()) + commandLine(xcrun, "simctl", "shutdown", simulatorDeviceName) + + doLast { + executionResult.get().assertNormalExitValue() + } + } + + tasks.withType().configureEach { + if (!HostManager.hostIsMac) { return@configureEach } + + dependsOn("bootIosSimulatorDevice") + finalizedBy("shutdownIosSimulatorDevice") + + standalone = false + device = simulatorDeviceName + } +} + // Publishing configurePublishing("aws-crt-kotlin")