Build swift package for simulator and device does not work anymore
See original GitHub issueHi guys, I really love this framework - it is awesome.
The only issue I run into now is, when using the newest android studio canary build 15 of android studio with the new build and compile configurations and options and preliminary support for Apple Silicon, only an ios-x86_64-simulator
framework is generated. The ios-arm64
framework is missing. The release notes for the new android studio: https://androidstudio.googleblog.com/2021/04/android-studio-arctic-fox-canary-15.html
The packForXCode
looks like this:
val packForXcode by tasks.creating(Sync::class) {
val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
val framework = kotlin.targets.getByName<KotlinNativeTarget>("ios").binaries.getFramework(mode)
val targetDir = File(buildDir, "xcode-frameworks")
group = "build"
dependsOn(framework.linkTask)
inputs.property("mode", mode)
from({ framework.outputDirectory })
into(targetDir)
}
tasks.getByName("build").dependsOn(packForXcode)
The further configuration in the kotlin {}
block for iOS looks like this atm:
kotlin {
android() {
publishAllLibraryVariants()
}
val iosTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
:: iosArm64
else
:: iosX64
iosTarget("ios") {
binaries {
framework {
baseName = "my-shared"
}
}
}
val ktorVersion = "1.4.0"
.
.
.
}
And my configuration for this framework looks like this:
multiplatformSwiftPackage {
val spmPath = "<my-spm-path>"
swiftToolsVersion("5.3")
spmPath?.apply {
outputDirectory(File(spmPath))
targetPlatforms {
iOS { v("14") }
}
}
}
Can you please help me with that? What can I change to make that work? I use the version 2.0.3
of your plugin.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:8
Top GitHub Comments
The solution by @ashley-figueira works fine. Basically replace the default
iosTarget
withios
(since iosTarget seems to be a workaround deprecated by the “hierarchical project structure” according to https://kotlinlang.org/docs/migrating-multiplatform-project-to-14.html#try-the-hierarchical-project-structure).I could then use the ‘shared kotlin’ package as a framework dependency on my ios swift package.
Additionally, this change does not seem to break the default ios project integration (I can still build an app that uses the shared module directly and run for device/simulator).
@rb090 If you are using this gradle plugin there is no reason you need the packForXcode is there? Have you added the two lines I mentioned to your gradle.properties file?
This is my complete builde.gradle.kts