0

I'm trying to import my ios framework, from where I'm getting this error:

fatal error: could not build module 'FRAMEWORK_IOS'

Also I successfully imported other third party frameworks like: mapbox and firebase framework.

Overall this error that I'm getting is not very clear and I cannot locate what is causing the problem, because if I directly load that custom framework from xcode it's gonna work as expected.

gradle:

ios {
val frameworkLocation = File("/Users/user/Desktop/MyProject/shared/src/iosArm64Main/SDK")
val frameworks = "-F$frameworkLocation"
compilations {
    @Suppress("UNUSED_VARIABLE")
    val main by getting {
        cinterops {
            val FRAMEWORK_IOS by creating {
                defFile = File("/Users/user/Desktop/MyProject/shared/src/nativeInterop/cinterop/FRAMEWORK_IOS.def")
                compilerOpts(frameworks)
            }
        }
    }
}
binaries.matching { it is org.jetbrains.kotlin.gradle.plugin.mpp.Framework }
    .configureEach {
        val framework = this as org.jetbrains.kotlin.gradle.plugin.mpp.Framework
        framework.linkerOpts(frameworks)
    }
}

def

language = Objective-C
modules = FRAMEWORK_IOS
linkerOpts = -framework FRAMEWORK_IOS

error:

Exception in thread "main" java.lang.Error: /var/folders/ll/7t94x_gn5nz24xb1f1v_02q40000gr/T/7671724635539436126.m:1:9: fatal error: could not build module 'FRAMEWORK_IOS'
at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:152)
at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesASTFiles(ModuleSupport.kt:68)
at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesInfo(ModuleSupport.kt:14)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.buildNativeLibrary(main.kt:515)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:266)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:76)
at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:45)
at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:38)
at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:60)

  FAILURE: Build failed with an exception.

  * What went wrong:
  Execution failed for task ':shared:cinteropFRAMEWORK_IOSIosArm64'.
  > Process 'command '/Applications/Android 
  Studio.app/Contents/jre/jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full 
insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task 
':shared:cinteropFRAMEWORK_IOSIosArm64'.
cross_flame
  • 840
  • 2
  • 11
  • 24
  • Did you fix it? Got the same problem on project which worked perfectly fine 3 days ago. No code changes made... – TomGrill Games Sep 22 '21 at 14:39
  • My problem was that I used iOS framework with C++ lib, where KMM is supporting only C code. My Solution was just to wrap the iOS framework C++ lib with a new iOS framework and that does the trick. – cross_flame Sep 24 '21 at 12:05

0 Answers0