ribesg
01/12/2021, 11:17 AM#import "BugsnagApp.h"
to something like #import <Bugsnag/BugsnagApp.h>
Error:
Exception in thread "main" java.lang.Error: /[…]/Carthage/Build/iOS/Bugsnag.framework/Headers/Bugsnag.h:28:9: fatal error: 'Bugsnag/BugsnagApp.h' file not found
at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:152)
at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.indexDeclarations(Indexer.kt:1003)
at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.buildNativeIndexImpl(Indexer.kt:992)
at org.jetbrains.kotlin.native.interop.indexer.NativeIndexKt.buildNativeIndex(NativeIndex.kt:91)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:267)
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)
My def file:
depends = Foundation
package = framework.Bugsnag
language = Objective-C
headers = Bugsnag.h
compilerOpts = -framework Bugsnag
linkerOpts = -framework Bugsnag
Gradle cinterop configuration:
compilations.getByName("main").cinterops.create("Bugsnag") {
defFile("src/iosMain/cinterop/Bugsnag.def")
includeDirs.allHeaders("$projectDir/Carthage/Build/iOS/Bugsnag.framework/Headers")
}
What can I do to make cinterop work with that commit’s change?ribesg
01/12/2021, 1:34 PMArtyom Degtyarev [JB]
01/12/2021, 1:39 PMHeaders
folder contents look like, the same as at the https://github.com/bugsnag/bugsnag-cocoa/tree/master/Bugsnag/include/Bugsnag?ribesg
01/12/2021, 1:40 PMribesg
01/12/2021, 1:40 PMArtyom Degtyarev [JB]
01/12/2021, 1:58 PMmodules
instead of headers
here. Can’t construct working example on my own, but I would guess it should look somehow similar to K/N platform libraries .defs(e.g. https://github.com/JetBrains/kotlin-native/blob/master/platformLibs/src/platform/osx/AppKit.def)ribesg
01/12/2021, 2:18 PMtargets.withType<KotlinNativeTarget> {
compilations.getByName("main").cinterops.create("Bugsnag") {
defFile("src/iosMain/cinterop/Bugsnag.def")
includeDirs.allHeaders(
"${project.carthageBuildDir}/Bugsnag.framework/Headers",
"${project.carthageBuildDir}/Bugsnag.framework/Modules"
)
}
}
And my def file to this:
depends = Foundation
package = framework.Bugsnag
language = Objective-C
modules = Bugsnag
compilerOpts = -framework Bugsnag
linkerOpts = -framework Bugsnag
And I get this error:
Exception in thread "main" java.lang.Error: /var/folders/6l/fxc2038542q1pfrjs6br35pw0000gn/T/7677652267403620526.m:1:9: fatal error: could not build module 'Bugsnag'
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)
ribesg
01/12/2021, 3:19 PMArtyom Degtyarev [JB]
01/12/2021, 3:43 PMTask :compileKotlinIos FAILED
, but on a simpler example everything worked fine. I’ve made the following:
1. added path to the framework, set as a compiler option under -F flag
2. changed include path to point onto the framework too.
For the example you shared, I’ve tried to do it as
compilations.getByName("main").cinterops.create("Bugsnag") {
defFile("src/iosMain/cinterop/Bugsnag.def")
//includeDirs(
// "$projectDir/carthage/Carthage/Build/iOS/Bugsnag.framework/Headers",
// "$projectDir/carthage/Carthage/Build/iOS/Bugsnag.framework/Modules"
//)
compilerOpts("-F$projectDir/carthage/Carthage/Build/iOS/","-I$projectDir/carthage/Carthage/Build/iOS/")
}
Please give it a try, and tell if this would work any better.ribesg
01/12/2021, 4:07 PM