Enol Sim贸n
10/09/2024, 8:59 AMGoogle-Maps-iOS-Utils
. I am using CocoaPods to be able to use the code in my Kotlin files. For GoogleMaps it works fine, but when I try to add the Google-Maps-iOS-Utils
pod, I am getting errors. (I continue in thread)Enol Sim贸n
10/09/2024, 3:08 PMv6.0.0
) requires GoogleMaps 9.0
, and for some reason, my project can only install the version 8.0.0
, if I try to install the GoogleMaps pod with higher version (8.3.0
, 8.3.1
, 8.4.0
, 9.0.0
, 9.1.0
and 9.1.1
) I get this error when I try to build in XCode:
Showing All Errors Only
Failed to load XCFramework at '/Users/user/myproject/iosApp/Pods/GoogleMaps/Base/Frameworks/GoogleMapsBase.xcframework': 'HeadersPath' is not supported for a 'framework' in library 'ios-arm64'.
2) As I have to stay in the version 8.0.0
, the latest version compatible of Google-Maps-iOS-Utils
is v5.0.0
. So I add in my `Podfile`:
# Uncomment the next line to define a global platform for your project
platform :ios, '16.0'
target 'iosApp' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks! :linkage => :static
# Pods for iosApp
pod 'shared', :path => '../shared'
pod 'GoogleMaps', '8.0.0'
pod 'Google-Maps-iOS-Utils', '5.0.0'
end
And in my build.gradle
cocoapods {
summary = "Some description for the Shared Module"
homepage = "Link to the Shared Module homepage"
version = "1.0"
ios.deploymentTarget = "16.0"
podfile = project.file("../iosApp/Podfile")
framework {
baseName = "shared"
isStatic = true
}
pod("GoogleMaps") {
extraOpts += listOf("-compiler-option", "-fmodules")
}
pod("Google-Maps-iOS-Utils") {
extraOpts += listOf("-compiler-option", "-fmodules")
}
}
I get the following errors when syncing the project (attached images). And when running in Xcode, everything looks to work fine until it gets the step:
> Task :shared:cinteropGoogle_Maps_iOS_UtilsIosSimulatorArm64 FAILED
Showing All Issues
Exception in thread "main" java.lang.Error: /var/folders/qn/1f2__ymn7rx9382fc4hcxqth0000gn/T/7410914245776930564.m:1:9: fatal error: module 'Google_Maps_iOS_Utils' not found
at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:328)
at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesASTFiles(ModuleSupport.kt:83)
at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesInfo(ModuleSupport.kt:15)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.buildNativeLibrary(main.kt:578)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:322)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLibSafe(main.kt:244)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.access$processCLibSafe(main.kt:1)
at org.jetbrains.kotlin.native.interop.gen.jvm.Interop.interop(main.kt:102)
at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:49)
at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:23)
at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:44)
Did somebody of you guys faced this issue or understands what is going on? Just as information I am using Macbook Pro M3 (i mention it beause of the arm-64
thing. Kotlin 2.0.21-RC
Thanks in advance!Mathew Dostal
10/20/2024, 5:09 PMpod("GoogleMaps") {
version = "9.0.0"
extraOpts += listOf("-compiler-option", "-fmodules")
}
pod("Google-Maps-iOS-Utils") {
moduleName = "GoogleMapsUtils"
version = "6.0.0"
extraOpts += listOf("-compiler-option", "-fmodules")
}
I import these into the core iOS App --
import GoogleMaps
import GoogleMapsUtils
If using in a KT compose view --
import cocoapods.GoogleMaps.GMSMarker
import cocoapods.GoogleMaps.GMSCameraPosition
import cocoapods.GoogleMaps.GMSMapViewDelegateProtocol
import cocoapods.Google_Maps_iOS_Utils.GMUClusterManager
import cocoapods.Google_Maps_iOS_Utils.GMUDefaultClusterIconGenerator
You can see the imports are a bit wonky there, but I've got it running. Now, full working? I've got some issues I'm trying to work through but i'm able to build and put both markers and clusters on the map atmMathew Dostal
10/20/2024, 5:09 PMMathew Dostal
10/20/2024, 5:11 PMEnol Sim贸n
10/20/2024, 5:12 PMEnol Sim贸n
10/20/2024, 5:12 PMMathew Dostal
10/20/2024, 5:13 PMEnol Sim贸n
10/20/2024, 5:14 PMMathew Dostal
10/20/2024, 5:15 PMEnol Sim贸n
10/20/2024, 5:17 PMremember
to the GMSMapView()
and GMUClusterManager(mapView, clusterAlgorithm, clusterRenderer)
, which are initialized outside of the UIKitView
and adding the markers in the update
blockMathew Dostal
10/20/2024, 5:20 PMEnol Sim贸n
10/20/2024, 5:21 PM@Composable
actual fun GoogleMapView(
items: ImmutableList<Location>
) {
val mapView = remember { GMSMapView() }
val clusterIconGenerator = GMUDefaultClusterIconGenerator()
val clusterAlgorithm = GMUNonHierarchicalDistanceBasedAlgorithm()
val clusterRenderer = GMUDefaultClusterRenderer(mapView, clusterIconGenerator)
val clusterManager =
remember {
GMUClusterManager(mapView, clusterAlgorithm, clusterRenderer)
}
UIKitView(
factory = {
...
mapView
},
update = {
mapView.clear()
clusterManager.clearItems()
if (items.isNotEmpty()) {
items.forEach { item ->
clusterManager.addItem(ClusterItem(item))
}
clusterManager.cluster()
}
},
properties =
UIKitInteropProperties(
interactionMode = UIKitInteropInteractionMode.NonCooperative,
),
modifier = modifier.fillMaxSize(),
onRelease = {
it.removeFromSuperview()
},
)
}
Mathew Dostal
10/20/2024, 9:47 PMMathew Dostal
10/21/2024, 7:29 PMval delegate = remember {
object : NSObject(), GMSMapViewDelegateProtocol {
override fun mapView(
mapView: GMSMapView,
didTapMarker: cocoapods.Google_Maps_iOS_Utils.GMSMarker,
): Boolean {
val userData = didTapMarker.userData()
if (userData is ShindigEvent) {
onMarkerClick(googleMapViewEntries[0])
}
return false
}
// Note: this shows an error,
// but it compiles and runs fine(!)
// Kotlin doesn't like the multi overload, but it is swift compliant
override fun mapView(
mapView: GMSMapView,
didTapInfoWindowOfMarker: cocoapods.Google_Maps_iOS_Utils.GMSMarker,
) {
val shindigEvent = (didTapInfoWindowOfMarker.userData() as ShindigEvent)
onMarkerInfoClick(shindigEvent)
}
// Note: this shows an error,
// but it compiles and runs fine(!)
// Kotlin doesn't like the multi overload, but it is swift compliant
override fun mapView(
mapView: GMSMapView,
didCloseInfoWindowOfMarker: cocoapods.Google_Maps_iOS_Utils.GMSMarker,
) {
val shindigEvent = (didCloseInfoWindowOfMarker.userData() as ShindigEvent)
onMarkerInfoClose(shindigEvent)
}
}
}
Enol Sim贸n
10/21/2024, 7:38 PMMathew Dostal
10/21/2024, 8:15 PM