I'm getting some errors after adding the GoogleMap...
# multiplatform
j
I'm getting some errors after adding the GoogleMaps pod to a KMM project. Could someone please help me with this?
Errors:
Copy code
> Task :shared:linkPodDebugFrameworkIosArm64 FAILED
warning: Cannot infer a bundle ID from packages of source files and exported dependencies, use the bundle name instead: shared. Please specify the bundle ID explicitly using the -Xbinary=bundleId=<id> compiler flag.
error: /Users/jaydenking/Downloads/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors
Please try to disable compiler caches and rerun the build. To disable compiler caches, add the following line to the gradle.properties file in the project's root directory:
    
    kotlin.native.cacheKind.iosArm64=none
    
Also, consider filing an issue with full Gradle log here: <https://kotl.in/issue>
The /Users/jaydenking/Downloads/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1.
output:
ld: warning: ignoring duplicate libraries: '-ldl'
ld: warning: object file (/Users/jaydenking/StudioProjects/The-Carbon-Conscious-Traveller/shared/build/cocoapods/synthetic/ios/build/Release-iphoneos/XCFrameworkIntermediates/GoogleMaps/Maps/GoogleMaps.framework/GoogleMaps) was built for newer 'iOS' version (14.0) than being linked (12.0)
ld: Undefined symbols:
  _GMSAreEqualOrBothNil, referenced from:
followed by a bunch of lines about
_GMS*
here's the build file for the shared module
Copy code
plugins {
    alias(libs.plugins.android.library)
    alias(libs.plugins.kotlin.multiplatform)
    alias(libs.plugins.sqldelight)
    alias(libs.plugins.native.cocoapods)
    alias(libs.plugins.jetbrains.compose)
}

kotlin {
    androidTarget {
        compilations.all {
            kotlinOptions {
                jvmTarget = libs.versions.kotlinJvmTarget.get()
            }
        }
    }

    listOf(iosX64(), iosArm64(), iosSimulatorArm64()).forEach {
        it.binaries.framework {
            baseName = "shared"
            binaryOption("bundleId", "com.mquniversity.tcct.iosApp")
        }
    }

    sourceSets {
        all {
            languageSettings.optIn("kotlinx.cinterop.ExperimentalForeignApi")
        }
        commonMain.dependencies {
            // implementation(libs.runtime)
            // implementation(libs.primitive.adapters)
            implementation(libs.koin.core)
            implementation(libs.kotlinx.datetime)
            // implementation(libs.coroutines.extensions)
            implementation(compose.runtime)
            implementation(compose.foundation)
            implementation(compose.ui)
            implementation(compose.material)
            implementation(compose.components.resources)
            api(libs.kmm.viewmodel.core)
        }
        androidMain.dependencies {
            implementation(libs.android.driver)
            implementation(libs.koin.androidx.compose)
            // implementation(libs.androidx.lifecycle.viewmodel.compose)
            implementation(libs.play.services.maps)
            // implementation(libs.google.maps.services)
            implementation(libs.play.services.location)
        }
        iosMain.dependencies {
            implementation(libs.native.driver)
        }
    }

    cocoapods {
        // version = "1.0"
        summary = "The Carbon-Conscious Traveller"
        // source = "<https://github.com/CocoaPods/Specs.git>"
        homepage = "<https://github.com/JaydenKing32/The-Carbon-Conscious-Traveller>"
        license = "MIT"
        ios.deploymentTarget = "15.0"
        podfile = project.file("../iosApp/Podfile")

        pod("GoogleMaps") {
            version = libs.versions.podsGoogleMaps.get()
            extraOpts += listOf("-compiler-option", "-fmodules")
        }

        framework {
            baseName = "shared"
            isStatic = false
        }
    }
}

android {
    namespace = "com.mquniversity.tcct.shared"
    compileSdk = libs.versions.androidCompileSdk.get().toInt()
    defaultConfig {
        minSdk = libs.versions.androidMinSdk.get().toInt()
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_21
        targetCompatibility = JavaVersion.VERSION_21
    }
    buildFeatures {
        compose = true
    }
    composeOptions {
        kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExtension.get()
    }
}

sqldelight {
    databases {
        create("AppDatabase") {
            packageName.set("com.mquniversity.tcct.shared.cache")
        }
    }
}
and here's the podfile
Copy code
target 'iosApp' do
  use_frameworks!
  platform :ios, '15.0'
  pod 'shared', :path => '../shared'
  pod 'GoogleMaps', '8.4.0'
end
j
I have it running, Hard to say what's different in your project setup... obvious thing is that my shared module is static and has extra option
Copy code
binaryOption("bundleVersion", "2")
isStatic = true
but not sure if it's going to help
but based on the error message
Cannot infer a bundle ID from packages of source files and exported dependencies
looks like your project setup has some issue... be also sure you have everything updated to latest stable versions... it might be very well some older bug
j
I can't use
isStatic = true
since I'm using SQLDelight and it's apparently incompatible with that. Which versions are you referring to exactly? I know that I need to keep some things at a lower version with KMM like AGP
j
I'm using
Copy code
kotlin = "1.9.23"
jvmtarget = "17"
sqldelight = "2.0.2"
jetbrains-compose-ui = "1.6.2"
I have sqldelight part of my project as well, and I do have it static... not sure why would sqldelight need
isStatic = false
but I'm not super experienced in KMP/iOS build pipeline... anyway in these cases, I usually go with try&error approach from very basic project template, there was always some stupid mistake I had in my project setup...
j
ok, I'll try switching some things around
yeah, when I change it to
isStatic = true
I get this error instead:
Copy code
ld: warning: ignoring duplicate libraries: '-ldl'
ld: framework 'GoogleMaps' not found
OK, it looks like I fixed it by getting SQLDelight to work with static linking by setting`-lsqlite3` linker flag to gradle and Xcode, Strangely, I then needed to set
isStatic = true
in both the binaries.framework block and the cocoapod's framework block in order to build with the GoogleMaps pod
163 Views