11plugins {
22 kotlin(" multiplatform" )
33 kotlin(" native.cocoapods" )
4+
45 id(" com.android.library" )
56
67 id(" convention.publication" )
78}
89
10+ val hostOs: String = System .getProperty(" os.name" )
11+ val isMacOS = hostOs == " Mac OS X"
12+ val isWindows = hostOs.startsWith(" Windows" )
13+
914kotlin {
1015 android() {
1116 publishLibraryVariants(" release" , " debug" )
1217 }
1318
14- listOf (iosArm64(), iosSimulatorArm64(), iosX64()).forEach { t ->
15- t.compilations.getByName(" main" ) {
16- val xlog by cinterops.creating {
17- defFile(" src/iosMain/cinterop/xlog.def" )
19+ if (isMacOS) {
20+ listOf (iosArm64(), iosSimulatorArm64(), iosX64()).forEach { t ->
21+ t.compilations.getByName(" main" ) {
22+ val xlog by cinterops.creating {
23+ defFile(" src/iosMain/cinterop/xlog.def" )
1824
19- includeDirs(" ${project.projectDir} /src/iosMain/objc" )
25+ includeDirs(" ${project.projectDir} /src/iosMain/objc" )
26+ }
2027 }
21- }
2228
23- // kmp doesn't support link to xcframework now,
24- // but actually we don't need to link it when build static framework
25- /* val libPath = hashMapOf(
29+ // kmp doesn't support link to xcframework now,
30+ // but actually we don't need to link it when build static framework
31+ /* val libPath = hashMapOf(
2632 "iosArm64" to "os-arm64",
2733 "iosSimulatorArm64" to "sim-arm64",
2834 "iosX64" to "sim-x64",
@@ -38,24 +44,31 @@ kotlin {
3844 )
3945 }
4046 }*/
41- }
47+ }
48+
49+ cocoapods {
50+ summary = " KMP wrapper for tencent mars xlog"
51+ homepage = " https://github.com/HackWebRTC/kmp-xlog"
52+ version = Consts .releaseVersion
53+ ios.deploymentTarget = Consts .iosDeploymentTarget
54+
55+ license = " { :type => 'MIT', :file => 'LICENSE'}"
56+ source = " { :http => '$homepage /releases/download/v$version /kmp_xlog.xcframework.zip' }"
57+ authors = " Piasy Xu"
58+
59+ extraSpecAttributes[" libraries" ] = " 'z'"
60+ extraSpecAttributes[" framework" ] = " 'SystemConfiguration'"
61+ framework {
62+ baseName = " kmp_xlog"
63+ isStatic = true
64+ embedBitcode(" disable" )
65+ }
66+ }
4267
43- cocoapods {
44- summary = " KMP wrapper for tencent mars xlog"
45- homepage = " https://github.com/HackWebRTC/kmp-xlog"
46- version = Consts .releaseVersion
47- ios.deploymentTarget = Consts .iosDeploymentTarget
48-
49- license = " { :type => 'MIT', :file => 'LICENSE'}"
50- source = " { :http => '$homepage /releases/download/v$version /kmp_xlog.xcframework.zip' }"
51- authors = " Piasy Xu"
52-
53- extraSpecAttributes[" libraries" ] = " 'z'"
54- extraSpecAttributes[" framework" ] = " 'SystemConfiguration'"
55- framework {
56- baseName = " kmp_xlog"
57- isStatic = true
58- embedBitcode(" disable" )
68+ js(IR ) {
69+ browser {
70+ }
71+ binaries.executable()
5972 }
6073 }
6174
@@ -67,29 +80,39 @@ kotlin {
6780 implementation(" io.mockk:mockk-common:${Consts .mockk} " )
6881 }
6982 }
83+
7084 val androidMain by getting
7185 val androidTest by getting {
7286 dependencies {
7387 implementation(" io.mockk:mockk:${Consts .mockk} " )
7488 }
7589 }
76- val iosArm64Main by getting
77- val iosSimulatorArm64Main by getting
78- val iosX64Main by getting
79- val iosMain by creating {
80- dependsOn(commonMain)
81- iosArm64Main.dependsOn(this )
82- iosSimulatorArm64Main.dependsOn(this )
83- iosX64Main.dependsOn(this )
84- }
85- val iosArm64Test by getting
86- val iosSimulatorArm64Test by getting
87- val iosX64Test by getting
88- val iosTest by creating {
89- dependsOn(commonTest)
90- iosArm64Test.dependsOn(this )
91- iosSimulatorArm64Test.dependsOn(this )
92- iosX64Test.dependsOn(this )
90+
91+ if (isMacOS) {
92+ val iosArm64Main by getting
93+ val iosSimulatorArm64Main by getting
94+ val iosX64Main by getting
95+ val iosMain by creating {
96+ dependsOn(commonMain)
97+ iosArm64Main.dependsOn(this )
98+ iosSimulatorArm64Main.dependsOn(this )
99+ iosX64Main.dependsOn(this )
100+ }
101+ val iosArm64Test by getting
102+ val iosSimulatorArm64Test by getting
103+ val iosX64Test by getting
104+ val iosTest by creating {
105+ dependsOn(commonTest)
106+ iosArm64Test.dependsOn(this )
107+ iosSimulatorArm64Test.dependsOn(this )
108+ iosX64Test.dependsOn(this )
109+ }
110+
111+ val jsMain by getting {
112+ dependencies {
113+ implementation(kotlin(" stdlib-js" ))
114+ }
115+ }
93116 }
94117 }
95118}
0 commit comments