Eric Smith
06/20/2024, 3:44 PMException in thread "main" java.lang.Error: /var/folders/97/s34y5jdx6lx7pq323l5dngxw0000gn/T/4761418149266185367.m:1:9: fatal error: module 'MapboxCommon' not found
.
It would be most helpful if somebody could point me to a working example of this. Thanks.Michael Krussel
06/20/2024, 6:51 PM.def
file is like
language = Objective-C
modules = MapboxCoreMaps MapboxWrapper
compilerOpts = -fmodules
Then I have this that configures the cinterop
fun KotlinNativeTarget.createInterops(framework: PangeaFramework, defFile: File, packageName: String, interopName: String) {
val frameworkSearchPaths = frameworkSearchPath(framework)
val frameworkSearchPathOptions = frameworkSearchPaths.map { "-F$it" }
with(compilations) {
getByName("main") {
cinterops {
create(interopName) {
this.defFile = defFile
packageName(packageName)
compilerOpts(frameworkSearchPathOptions)
}
}
}
}
}
And I use the KotlinTarget.targetName
to determine which architecture to use for the search path inside each of Mapbox's xcframeworks so that I'm interoping with a specific framework instead of the xcframework.Eric Smith
06/20/2024, 8:29 PMMichael Krussel
06/20/2024, 8:58 PMios-arm64_x86_64-simulator
for both iosX64
and iosSimulatorArm64
• MapboxWrapper is a module I created that wraps Mapbox's Swift API with an Objective-C compatible API. It just wraps the functionality that we need.
• MapboxMaps cannot be cineteropped because it is Swift with no Objective-C bindings. MapboxWrapper depends on it internally but not in the public API.Eric Smith
06/20/2024, 9:01 PMMichael Krussel
06/20/2024, 9:02 PMEric Smith
06/20/2024, 9:04 PMMichael Krussel
06/20/2024, 9:05 PMCustomLayerHost
.Michael Krussel
06/20/2024, 9:09 PMEric Smith
06/20/2024, 9:10 PMEric Smith
06/21/2024, 9:15 PMld: warning: Could not find or use auto-linked framework 'MapboxCoreMaps': framework 'MapboxCoreMaps' not found
Following the instructions on kotlinlang.org, I’ve added this block to my iosTargets block:
iosTarget.binaries.all {
// Tell the linker where the framework is located.
linkerOpts(
"-framework", "MapboxCoreMaps", "-Fsrc/iosFrameworks/MapboxCoreMaps.xcframework/$subDir",
"-framework", "MapboxMaps", "-Fsrc/iosFrameworks/MapboxMaps.xcframework/$subDir",
)
}
Where iosTarget
is the KotlinNativeTarget
and subDir
is the “ios-arm64” or “ios-arm64_x86_64-simulator” as appropriate.
Any suggestions as to why it’s not finding the frameworks?Michael Krussel
06/24/2024, 1:38 PM/**
* Configure the project to depend on [frameworks].
*/
fun Project.dependOnFrameworks(frameworks: Iterable<PangeaFramework>) {
tasks.withType<KotlinNativeTest> {
environment(
"SIMCTL_CHILD_DYLD_FRAMEWORK_PATH",
frameworks.flatMap { frameworkSearchPath(it, targetName!!) }
.joinToString(separator = ":")
)
}
project.configureIosTargets { target ->
val searchPaths = frameworks.flatMap { target.frameworkSearchPath(it) }.map { "-F$it" }
target.binaries.configureEach {
linkerOpts(searchPaths)
}
}
}
Eric Smith
06/24/2024, 3:15 PMEric Smith
06/24/2024, 3:55 PM