@@ -14,6 +14,21 @@ kotlin {
1414 targets {
1515 js()
1616 jvm()
17+ // iOS commented out b/c appling test to JS & iOS does not work. Comment JS tests for iOS to work
18+
19+ def buildForDevice = project. findProperty(" device" )?. toBoolean() ?: false
20+ def iosPreset = (buildForDevice) ? presets. iosArm64 : presets. iosX64
21+ fromPreset(iosPreset, ' ios' ) {
22+ binaries {
23+ framework {
24+ // Disable bitcode embedding for the simulator build.
25+ if (! buildForDevice) {
26+ embedBitcode(" disable" )
27+ }
28+ }
29+ }
30+ }
31+
1732 }
1833 sourceSets {
1934 commonMain {
@@ -47,16 +62,52 @@ kotlin {
4762 implementation kotlin(" stdlib-js" )
4863 }
4964 }
65+ iosTest {
66+ dependsOn commonTest
67+ }
68+
69+ }
70+
71+ }
72+
5073
74+ task iosTest {
75+ def device = project. findProperty(" iosDevice" )?. toString() ?: " iPhone 8"
76+ dependsOn ' linkDebugTestIos'
77+ group = JavaBasePlugin . VERIFICATION_GROUP
78+ description = " Runs tests for target 'ios' on an iOS simulator"
79+
80+ doLast {
81+ def binary = kotlin. targets. ios. binaries. getTest(' DEBUG' ). outputFile
82+ exec {
83+ commandLine ' xcrun' , ' simctl' , ' spawn' , device, binary. absolutePath
84+ }
5185 }
86+ }
5287
88+ task copyFramework {
89+ def buildType = project. findProperty(" kotlin.build.type" ) ?: " DEBUG"
90+ dependsOn " link${ buildType.toLowerCase().capitalize()} FrameworkIos"
91+
92+ doLast {
93+ def srcFile = kotlin. targets. ios. binaries. getFramework(buildType). outputFile
94+ def targetDir = getProperty(" configuration.build.dir" )
95+ copy {
96+ from srcFile. parent
97+ into targetDir
98+ include ' greeting.framework/**'
99+ include ' greeting.framework.dSYM'
100+ }
101+ }
53102}
54103
104+
105+
55106// workaround for https://youtrack.jetbrains.com/issue/KT-27170
56107configurations {
57108 compileClasspath
58109}
59-
110+ /*
60111//Workaround to copy kotlin libraries so they are visible during testing
61112def jsLibDir = "$compileKotlinJs.destinationDir/lib"
62113def jsTestLibDir = "$compileTestKotlinJs.destinationDir/lib"
@@ -99,4 +150,6 @@ task runMocha(type: NodeTask, dependsOn: [installMocha, jsMainClasses, jsTestCla
99150 script = file("$nodeWorkingDir/node_modules/mocha/bin/mocha")
100151 args = [compileTestKotlinJs.outputFile]
101152}
102- jsTest. dependsOn runMocha
153+ jsTest.dependsOn runMocha
154+
155+ */
0 commit comments