crumpf
11/18/2021, 9:13 PMimport org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
val bitcode: String = if ("release".equals(configuration, true)) "bitcode" else "marker"
val iosFrameworkName = "FooFramework"
kotlin {
val xcf = XCFramework(iosFrameworkName)
ios {
binaries.framework {
xcf.add(this)
}
}
val iosTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget = when {
System.getenv("SDK_NAME")?.startsWith("iphoneos") == true -> ::iosArm64
System.getenv("NATIVE_ARCH")?.startsWith("arm") == true -> ::iosSimulatorArm64
else -> ::iosX64
}
iosTarget("ios") {}
cocoapods {
summary = "summary here"
homepage = "<https://www.example.com>"
ios.deploymentTarget = "10.0"
podfile = project.file("../iosApp/Podfile")
framework {
baseName = iosFrameworkName
freeCompilerArgs += listOf("-module-name", "FOO")
embedBitcode(bitcode)
}
pod("AFNetworking", "~> 4.0.1")
}
}
First question: Am I doing it wrong? 😀
Second question: Is it right to configure the framework (baseName, module-name, etc) inside the cocoapods
extension instead of the ios
target?
Third question: When set up this way, the iosTarget
workaround to for the IDE in conjunction with cocoapods reports exceptions about the x64 architecture already having a binary:
Cannot add binary podDebugFramework dependency to default fat framework
java.lang.IllegalArgumentException: This fat framework already has a binary for architecture `x64` (podDebugFramework for target `iosX64`)…
Cannot add binary podReleaseFramework dependency to default fat framework
java.lang.IllegalArgumentException: This fat framework already has a binary for architecture `x64` (podReleaseFramework for target `iosX64`)…
Even though things seem to build successfully, even with these pod<config>Framework exceptions, is there a possibility of a problem rearing its head? Is there something I can do to clean the exceptions up?
references:
Build XCFramework: https://kotlinlang.org/docs/mpp-build-native-binaries.html#build-xcframeworks
iOS dependencies with CocoaPods: https://kotlinlang.org/docs/kmm-add-dependencies.html#with-cocoapods
Note for iOS dependencies needing workaround to get code completion/highlighting in the IDE for the 3rd party libs
https://kotlinlang.org/docs/kmm-add-dependencies.html#workaround-to-enable-ide-support-for-the-shared-ios-source-set
Slack Conversation