Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

Can't add submodule cinterops #3600

Closed
artemsivcev opened this issue Nov 21, 2019 · 13 comments
Closed

Can't add submodule cinterops #3600

artemsivcev opened this issue Nov 21, 2019 · 13 comments

Comments

@artemsivcev
Copy link

I'm successfully added FirebaseMLVision, but this still need common lib.

Build.gradle:

        configure([targets.iosX64,
                   targets.iosArm64
        ]) {
            compilations.main.source(sourceSets.iosMain)
            compilations.test.source(sourceSets.iosTest)
            compilations["main"].cinterops {
...
                FirebaseMLVision {
                    packageName 'cocoapods.FirebaseMLVision'
                    defFile = file("$projectDir/src/iosMain/c_interop/FirebaseMLVision.def")
                    includeDirs("$projectDir/../ios_test/Pods/FirebaseMLVision", "$projectDir/../ios_test/Pods/FirebaseMLCommon")
                    compilerOpts("-F$projectDir/src/iosMain/c_interop/modules/FirebaseMLVision-${versions.firebaseMLVisionIos}")
                }
                FirebaseMLVisionTextModel {
                    packageName 'cocoapods.FirebaseMLVisionTextModel'
                    defFile = file("$projectDir/src/iosMain/c_interop/FirebaseMLVisionTextModel.def")
                    includeDirs("$projectDir/../ios_test/Pods/FirebaseMLVision")
                    compilerOpts("-F$projectDir/src/iosMain/c_interop/modules/FirebaseMLVisionTextModel-${versions.firebaseMLVisionTextModelIos}")
                }
...

And an error:

Exception in thread "main" java.lang.Error: /Users/User/Documents/multiplatform/lib/src/iosMain/c_interop/modules/FirebaseMLVisionTextModel-0.19.0/FirebaseMLVisionTextModel.framework/Modules/module.modulemap:3:10: error: inferred submodules require a module with an umbrella
	at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:146)
	at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesASTFiles(ModuleSupport.kt:67)
	at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesInfo(ModuleSupport.kt:13)
	at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.buildNativeLibrary(main.kt:359)
	at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:220)
	at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:38)
	at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:69)
	at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:18)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dx-ocr-lib:cinteropFirebaseMLVisionTextModelIosArm64'.
> Process 'command '/Applications/IntelliJ IDEA CE.app/Contents/jbr/Contents/Home/bin/java'' finished with non-zero exit value 1

Some one see this before? I think it's because FirebaseMLVisionTextModel didn't have any headers. How can I compile this framework then?

@artemsivcev
Copy link
Author

I see this error because FirebaseMLVisionTextModel didnt have "umbrella header" in module.modulemap. How can I resolve it in Kotlin?

@artemsivcev
Copy link
Author

I added empty headers to framework and it's successfully compile. But I think thats no gona work

@artdfel
Copy link
Contributor

artdfel commented Nov 22, 2019

Please extend the report with .def files contents.

@artemsivcev
Copy link
Author

Please extend the report with .def files contents.

FirebaseMLVision.def

language = Objective-C
modules = FirebaseMLVision
compilerOpts = -framework FirebaseMLVision
linkerOpts = -framework FirebaseMLVision

FirebaseMLVisionTextModel.def

language = Objective-C
modules = FirebaseMLVisionTextModel
compilerOpts = -framework FirebaseMLVisionTextModel
linkerOpts = -framework FirebaseMLVisionTextModel

@SvyatoslavScherbina
Copy link
Collaborator

Actually FirebaseMLVisionTextModel.framework is not importable neither to Swift nor to Objective-C (with @import). For example,

import FirebaseMLVisionTextModel

can't be compiled with Swift compiler, which would report the same "inferred submodules require a module with an umbrella" error.

In other word, it doesn't provide a correct module. That's why it can't be handled by cinterop with modules = in .def file.

@artemsivcev
Copy link
Author

artemsivcev commented Nov 22, 2019

Ok, but how can I compile it or modules like this in my multiplatform lib anyway?

@artemsivcev
Copy link
Author

Just del language and module sections? Thats it? Not be so ez...

@SvyatoslavScherbina
Copy link
Collaborator

You don't need processing FirebaseMLVisionTextModel with cinterop because it doesn't contain any public API. You can discover this fact by looking inside FirebaseMLVisionTextModel.framework: it lacks both Headers directory and Swift modules.

@artemsivcev
Copy link
Author

Then I don't understand how to add this framework to my project. Without it FirebaseMLVision didn't recognise anything. Any ideas?

@SvyatoslavScherbina
Copy link
Collaborator

It should be enough to make your binary link with this framework. This can be achieved in different ways. The simplest one is probably to add -framework FirebaseMLVisionTextModel to linkerOpts in FirebaseMLVision.def.

@artemsivcev
Copy link
Author

Hmmm... It's not so clear, but I try it out. Thx!

@ilmat192
Copy link
Contributor

@artemsivcev, did the approach with -framework FirebaseMLVisionTextModel in linkerOpts help you? Could we close the issue?

@ilmat192
Copy link
Contributor

According to migrating issue tracking to YouTrack, closing this issue as answered. If you still have some reports/questions, feel free to open an issue in YoutTrack or ask us in Slack.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants