11import java.util.*
22import java.text.SimpleDateFormat
3+ import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
4+
35
46plugins {
5- kotlin(" multiplatform" ) version " 1.5.10 "
7+ kotlin(" multiplatform" ) version " 1.5.30 "
68 id(" com.android.library" )
79}
810
911val libName = " LibraryName"
10- val libVersionName = " 1.0.1 "
12+ val libVersionName = " 1.0.2 "
1113group = " com.prof18"
1214version = libVersionName
1315
1416repositories {
1517 google()
16- jcenter()
1718 mavenCentral()
1819}
1920
2021kotlin {
22+ val xcFramework = XCFramework (libName)
23+
2124 android()
2225 ios {
23- binaries.framework(libName)
26+ binaries.framework(libName) {
27+ xcFramework.add(this )
28+ }
2429 }
30+
2531 sourceSets {
2632 val commonMain by getting
2733 val commonTest by getting {
@@ -46,80 +52,6 @@ kotlin {
4652 }
4753
4854 tasks {
49- register(" buildDebugXCFramework" , Exec ::class .java) {
50- description = " Create a Debug XCFramework"
51-
52- dependsOn(" link${libName} DebugFrameworkIosArm64" )
53- dependsOn(" link${libName} DebugFrameworkIosX64" )
54-
55- val arm64FrameworkPath = " $rootDir /build/bin/iosArm64/${libName} DebugFramework/${libName} .framework"
56- val arm64DebugSymbolsPath = " $rootDir /build/bin/iosArm64/${libName} DebugFramework/${libName} .framework.dSYM"
57-
58- val x64FrameworkPath = " $rootDir /build/bin/iosX64/${libName} DebugFramework/${libName} .framework"
59- val x64DebugSymbolsPath = " $rootDir /build/bin/iosX64/${libName} DebugFramework/${libName} .framework.dSYM"
60-
61- val xcFrameworkDest = File (" $rootDir /../kmp-xcframework-dest/$libName .xcframework" )
62- executable = " xcodebuild"
63- args(mutableListOf<String >().apply {
64- add(" -create-xcframework" )
65- add(" -output" )
66- add(xcFrameworkDest.path)
67-
68- // Real Device
69- add(" -framework" )
70- add(arm64FrameworkPath)
71- add(" -debug-symbols" )
72- add(arm64DebugSymbolsPath)
73-
74- // Simulator
75- add(" -framework" )
76- add(x64FrameworkPath)
77- add(" -debug-symbols" )
78- add(x64DebugSymbolsPath)
79- })
80-
81- doFirst {
82- xcFrameworkDest.deleteRecursively()
83- }
84- }
85-
86- register(" buildReleaseXCFramework" , Exec ::class .java) {
87- description = " Create a Release XCFramework"
88-
89- dependsOn(" link${libName} ReleaseFrameworkIosArm64" )
90- dependsOn(" link${libName} ReleaseFrameworkIosX64" )
91-
92- val arm64FrameworkPath = " $rootDir /build/bin/iosArm64/${libName} ReleaseFramework/${libName} .framework"
93- val arm64DebugSymbolsPath =
94- " $rootDir /build/bin/iosArm64/${libName} ReleaseFramework/${libName} .framework.dSYM"
95-
96- val x64FrameworkPath = " $rootDir /build/bin/iosX64/${libName} ReleaseFramework/${libName} .framework"
97- val x64DebugSymbolsPath = " $rootDir /build/bin/iosX64/${libName} ReleaseFramework/${libName} .framework.dSYM"
98-
99- val xcFrameworkDest = File (" $rootDir /../kmp-xcframework-dest/$libName .xcframework" )
100- executable = " xcodebuild"
101- args(mutableListOf<String >().apply {
102- add(" -create-xcframework" )
103- add(" -output" )
104- add(xcFrameworkDest.path)
105-
106- // Real Device
107- add(" -framework" )
108- add(arm64FrameworkPath)
109- add(" -debug-symbols" )
110- add(arm64DebugSymbolsPath)
111-
112- // Simulator
113- add(" -framework" )
114- add(x64FrameworkPath)
115- add(" -debug-symbols" )
116- add(x64DebugSymbolsPath)
117- })
118-
119- doFirst {
120- xcFrameworkDest.deleteRecursively()
121- }
122- }
12355
12456 register(" publishDevFramework" ) {
12557 description = " Publish iOs framework to the Cocoa Repo"
@@ -129,10 +61,15 @@ kotlin {
12961 commandLine(" git" , " checkout" , " develop" ).standardOutput
13062 }
13163
132- dependsOn(" buildDebugXCFramework " )
64+ dependsOn(" assemble ${libName} DebugXCFramework " )
13365
134- // Replace
13566 doLast {
67+
68+ copy {
69+ from(" $buildDir /XCFrameworks/debug" )
70+ into(" $rootDir /../kmp-xcframework-dest" )
71+ }
72+
13673 val dir = File (" $rootDir /../kmp-xcframework-dest/$libName .podspec" )
13774 val tempFile = File (" $rootDir /../kmp-xcframework-dest/$libName .podspec.new" )
13875
@@ -190,10 +127,16 @@ kotlin {
190127 }
191128
192129 // Create Release Framework for Xcode
193- dependsOn(" buildReleaseXCFramework " )
130+ dependsOn(" assemble ${libName} ReleaseXCFramework " )
194131
195132 // Replace
196133 doLast {
134+
135+ copy {
136+ from(" $buildDir /XCFrameworks/release" )
137+ into(" $rootDir /../kmp-xcframework-dest" )
138+ }
139+
197140 val dir = File (" $rootDir /../kmp-xcframework-dest/$libName .podspec" )
198141 val tempFile = File (" $rootDir /../kmp-xcframework-dest/$libName .podspec.new" )
199142
0 commit comments