darkmoon_uk
01/11/2021, 11:51 PMcinterop
fails for a Cocoapod?
No useful output; the Java process exited non-zero 🤷
Knowing what the cinterop
command line executed by podImport
task is, would be a help to start diagnosing/tweaking from the command line.
Anyone have an example of 'manually' driving cinterop against a Cocoapod?Artyom Degtyarev [JB]
01/12/2021, 10:33 AM--debug
flag?darkmoon_uk
01/12/2021, 12:05 PMcinterop
call from terminal. As the Cocoapods plugin hides this I'll need to create a best-guess def file to recreate the problem. Is there any shortcut you know of to achieve this? Thanks.Artyom Degtyarev [JB]
01/12/2021, 12:09 PM./gradlew :shared:podImport --debug
I got this output:
Build operation 'Resolve files of :shared:iosX64SDWebImageCInterop' completed
2021-01-12T13:36:10.043+0300 [INFO] [org.gradle.api.Project] Run tool: "cinterop" with args: -o /Users/artyom.degtyarev/AndroidStudioProjects/WizardBorn/shared/build/classes/kotlin/iosX64/main/shared-cinterop-SDWebImage.klib -target ios_x64 -def /Users/artyom.degtyarev/AndroidStudioProjects/WizardBorn/shared/build/cocoapods/defs/SDWebImage.def -pkg cocoapods.SDWebImage -compiler-option -F/Users/artyom.degtyarev/AndroidStudioProjects/WizardBorn/shared/build/cocoapods/synthetic/iosX64/shared/build/Release-iphonesimulator/AFNetworking -compiler-option -F/Users/artyom.degtyarev/AndroidStudioProjects/WizardBorn/shared/build/cocoapods/synthetic/iosX64/shared/build/Release-iphonesimulator/SDWebImage -compiler-option -F/Users/artyom.degtyarev/AndroidStudioProjects/WizardBorn/shared/build/cocoapods/synthetic/iosX64/shared/Pods/../../../../framework -Xmodule-name com.example.wizardborn:shared-cinterop-SDWebImage
As you can see, .def file should be available at build/cocoapods/defs
, arguments could also be grabbed from this output.darkmoon_uk
01/12/2021, 1:41 PM.def
for this Bluedot Point SDK Cocoapod contained only:
language = Objective-C
modules = BluedotPointSDK
So I tried this:
~/.konan/kotlin-native-prebuilt-macos-1.4.21/bin/cinterop -def ./shared/build/cocoapods/defs/BluedotPointSDK.def -staticLibrary ./iosApp/Pods/BluedotPointSDK/PointSDK/BDPointSDK.framework/BDPointSDK
Exception in thread "main" java.lang.Error: /var/folders/88/ryrlz__94m59h1pnvb2z7zg00000gn/T/13800816599543313007.m:1:9: fatal error: module 'BluedotPointSDK' not found
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:507)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:265)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:73)
at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:45)
at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:19)
at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:41)
.framework
package, as an argument to -staticLibrary
is what cinterop
expects, but it seemed reasonable.Artyom Degtyarev [JB]
01/14/2021, 12:58 PMmoduleName
to be corresponding to the framework’s name. In this case, your build.gradle.kts
should contain something like
cocoapods {
summary = "CocoaPods test library"
homepage = "<https://github.com/JetBrains/kotlin>"
pod("BluedotPointSDK", moduleName= "BDPointSDK")
• The second problem is that this framework use @import
, which needs -fmodules
flag to be set. This is not supported by the cinterop
tool at the moment, please see this issue: https://youtrack.jetbrains.com/issue/KT-39120
Unfortunately, the second problem does not have any workarounds(as far as I’m informed).