title: Kotlin-multiplatform: How to execute iOS unit tests
body: <p>I'm working on a Kotlin-multiplatform library for Android and iOS. I want to write some platform-specific unit test. The tests run as expected for the shared code and Android but not for iOS.</p>
  
  <p>Below the <code>build.gradle</code> file of the shared code module.</p>
  
  <pre><code>apply plugin: "kotlin-multiplatform"
  
  kotlin {
      targets {
          final def iOSTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") \
                                ? presets.iosArm64 : presets.iosX64
  
          fromPreset(iOSTarget, 'iOS') {
              compilations.main.outputKinds('FRAMEWORK')
          }
  
          fromPreset(presets.jvm, 'android')
      }
  
      sourceSets {
          commonMain.dependencies {
              implementation "org.jetbrains.kotlin:kotlin-stdlib-common"
          }
          commonTest.dependencies {
              implementation 'org.jetbrains.kotlin:kotlin-test'
              implementation 'org.jetbrains.kotlin:kotlin-test-junit'
          }
          androidMain.dependencies {
              implementation "org.jetbrains.kotlin:kotlin-stdlib"
          }
          androidTest {
              dependencies {
                  implementation 'org.jetbrains.kotlin:kotlin-test'
                  implementation 'org.jetbrains.kotlin:kotlin-test-junit'
              }
          }
          iOSMain.dependencies {
          }
          iOSTest.dependencies {
              implementation 'org.jetbrains.kotlin:kotlin-test'
              implementation 'org.jetbrains.kotlin:kotlin-test-junit'
          }
      }
  }
  
  // workaround for https://youtrack.jetbrains.com/issue/KT-27170
  configurations {
      compileClasspath
  }
  
  task packForXCode(type: Sync) {
      final File frameworkDir = new File(buildDir, "xcode-frameworks")
      final String mode = project.findProperty("XCODE_CONFIGURATION")?.toUpperCase() ?: 'DEBUG'
  
      inputs.property "mode", mode
      dependsOn kotlin.targets.iOS.compilations.main.linkTaskName("FRAMEWORK", mode)
  
      from { kotlin.targets.iOS.compilations.main.getBinary("FRAMEWORK", mode).parentFile }
      into frameworkDir
  
      doLast {
          new File(frameworkDir, 'gradlew').with {
              text = "#!/bin/bash\nexport 'JAVA_HOME=${System.getProperty("java.home")}'\ncd '${rootProject.rootDir}'\n./gradlew \$@\n"
              setExecutable(true)
          }
      }
  }
  
  tasks.build.dependsOn packForXCode
  </code></pre>
  
  <p>and the structure of the <code>SharedCode</code> module is:</p>
  
  <pre><code>└── src
      ├── commonMain
      │   └── kotlin
      ├── commonTest
      │   └── kotlin
      ├── androidMain
      │   └── kotlin
      ├── androidTest
      │   └── kotlin
      ├── iOSMain
      │   └── kotlin
      └── iOSTest
          └── kotlin
  </code></pre>
  
  <p>The tests added in the <code>androidTest</code> and <code>commonTest</code> folders do run as expected but the ones added in the <code>iOSTest</code> do not run.</p>
  
  <p>However, if I replace the the line <code>fromPreset(iOSTarget, 'iOS') { compilations.main.outputKinds('FRAMEWORK') }</code> for <code>fromPreset(presets.macosX64, 'macos')</code> and update the directory names accordly, the tests in the <code>macosTest</code> folder do run as expected.</p>
  
  <p>Why it is not possible to run iOS test when building iOS frameworks? Any idea about what I'm doing wrong or how I can make this works? :)</p>