Having some trouble getting the cocoapods plugin t...
# ios
d
Having some trouble getting the cocoapods plugin to work. We have one gradle module configured with the following:
Copy code
cocoapods {
        summary = "mapbox framework"
        homepage = "<https://github.com/cuhacking/atlas>"

        frameworkName = "MapStuff"

        ios.deploymentTarget = Versions.ios

        pod("Mapbox-iOS-SDK", "~> 5.9", moduleName = "Mapbox")
    }
this module isn't imported as a framework^, it's just more convenient to manage pod dependencies with the plugin and then we have another module called "common" configured like so:
Copy code
cocoapods {
        summary = "mapbox framework"
        homepage = "<https://github.com/cuhacking/atlas>"
        podfile = project.file("../ios/Podfile")

        frameworkName = "Common"

        ios.deploymentTarget = Versions.ios
    }
The Common framework depends on the first module^ and is then included as a dependency for our iOS app.
pod 'common', :path => '../common'
Everything builds normally until trying to build in Xcode where it fails with a "module 'Mapbox' not found" on the cinterop step. Tried just about everything at this point, and I saw a similar-looking issue about subspecs but AFAIK this isn't related since the Mapbox-iOS-SDK pod can be included and I have been able to before.
I was able to wrok around this by adding the Mapbox-iOS-SDK pod to the common module as well. Seems like a bug?
Not really sure how (or really, what) to report
i
Hi @Derek Ellis. This is a known problem: https://youtrack.jetbrains.com/issue/KT-41830. The root cause is that the CocoaPods plugin doesn't propagate dependencies on pods through regular Gradle dependencies. To workaround this problem, you can manual add the dependency on
Mapbox-iOS-SDK
to a podspec file generated for the
common
module. You can automate this action by editing the
podspec
task. To do this, add this snippet to your build.gradle.kts in the
common
module:
Copy code
tasks["podspec"].doLast {
    val podspec = file("${project.name.replace("-", "_")}.podspec")
    val podspecContent = podspec.readLines().toMutableList()
    val endIndex = podspecContent.indexOfLast { it == "end" }
    podspecContent.add(endIndex, "    spec.dependency 'Mapbox-iOS-SDK', '~> 5.9'")
    podspec.writeText(podspecContent.joinToString(separator = "\n"))
}
👍 1