I am developing a Kotlin Multiplatform project that includes TensorFlow Lite for both iOS and Android targets. I can install CocoaPods and use TensorFlow Lite within iOS, but when I attempt to access it from Kotlin Multiplatform, my Xcode build fails. Below is the relevant configuration from my build.gradle.kts for the shared module:
plugins { kotlin("multiplatform") kotlin("native.cocoapods") id("com.android.library")}@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class)kotlin { targetHierarchy.default() androidTarget { compilations.all { kotlinOptions { jvmTarget = "1.8" } } } iosX64() iosArm64() iosSimulatorArm64() cocoapods { summary = "Machine Learning on KMP" homepage = "https://company.com" version = "1.0" pod("TensorFlowLiteObjC") { moduleName = "TFLTensorFlowLite" podfile = file("../iosSicuraApp/Podfile") } } sourceSets { val commonMain by getting {} val commonTest by getting { dependencies { implementation(kotlin("test")) implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${Versions.kotlinCoroutinesNative}") } } }}android { namespace = "com.company.customTFLib" compileSdk = 34 defaultConfig { minSdk = 24 }}
When I try to build, I get the following error in Xcode:
> Task :shared:linkDebugFrameworkIosSimulatorArm64 FAILEDld: framework 'TensorFlowLiteC' not found
The error suggests that the TensorFlowLiteC framework is not being found during the linking phase.
What I have tried:
- Ensuring that CocoaPods are correctly installed and accessible.
- Verifying paths and dependencies in the Podfile and build.gradle.kts.
- Cleaning and rebuilding the project.
Questions:
- How can I resolve the linking error regarding the TensorFlowLiteC framework not being found?
- Are there any specific configurations or settings that I should check or modify in my - - Kotlin Multiplatform setup to ensure that the iOS build can correctly link to the TensorFlowLiteC framework?
- Any insights or suggestions would be greatly appreciated!