I'm working as per the KMM tutorial in https://kotlinlang.org/docs/mobile/integrate-in-existing-app.htm. When I reach the the step ./gradlew packForXcode
, it will fail with
* What went wrong:
Task 'packForXcode' not found in root project 'Simple Login'.
I suspect the reason is the old KMM has packForXcxode
for it's iOS framework.
However, the new one is now with Cocoapod instead
What's the equivalent ./gradlew packForXcode
for KMM with Cocoapod
(FYI, the KMM version I use is 0.2.5(202-1.5.10-834-IJ)-3 Plugin)
packForXcode
has been removed from the latest plugin versions, you could use this snippet:
val packForXcode by tasks.creating(Sync::class) {
group = "build"
val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
val target = if(System.getenv("SDK_NAME").orEmpty().startsWith("macosx")) "macOS" else "ios"
val framework =
kotlin.targets.getByName<KotlinNativeTarget>(target).binaries.getFramework(mode)
inputs.property("mode", mode)
dependsOn(framework.linkTask)
val targetDir = File(buildDir, "xcode-frameworks")
from({ framework.outputDirectory })
into(targetDir)
}
(It might need some tweaks for your project)