touchlab-lab / KotlinCocoapods

Apache License 2.0
75 stars 6 forks source link

Fails silently when adding dependencies #18

Open CrispBull opened 3 years ago

CrispBull commented 3 years ago

In my project, I added CouchbaseLite pod dependency, it gradle syncs correctly but after that I can't find the dependency. In my shared grade file, I have the following snippet

cocoapodsext {
        summary = "TBC"
        homepage = "TBC"
        pod("AFNetworking")
        pod("CouchbaseLite")
    }

After gradle sync (success), I can only find the AFNetworking but CouchbaseLite doesn't work. What could be wrong and how can I fix it? Thanks

Edit: I have tried several ios libraries with this plugin and even a wrong dependency like pod("fjsljfa;fnajfd") would gradle sync correctly. So it seems like errors are failing silently.

russhwolf commented 3 years ago

Do you know if the same thing happens with the official cocoapods plugin?

jeffdgr8 commented 3 years ago

We finally got this working with the official cocoapods plugin after encountering several bugs. This is the relevant parts of our config:

cocoapods {
    summary = "..."
    homepage = "..."
    ios.deploymentTarget = "9.0"
    pod("CouchbaseLite-Enterprise", version = "~> 2.8.1", moduleName = "CouchbaseLite")
}

targets.withType<KotlinNativeTarget>().all {
    // Workaround for 'CBLQueryMeta' is going to be declared twice https://youtrack.jetbrains.com/issue/KT-41709
    compilations["main"].cinterops["CouchbaseLite"].extraOpts("-compiler-option", "-DCBLQueryMeta=CBLQueryMetaUnavailable")
}

Is there a way to specify ios.deploymentTarget with your plugin? frameworkName and podfile are also not available in the cocoapodsext block.

Using this config with your plugin ends up failing on the compilations["main"].cinterops["CouchbaseLite"]... line with the error DefaultCInteropSettings with name 'CouchbaseLite' not found.. If I comment out that line, then the Gradle sync completes, but no CouchbaseLite-Enterprise c-interop is generated, which is what @CrispBull is describing as failing silently. The IDE doesn't have access to the pod's API for code completion.

If I compile the module, then I get the error:

> Task :shared:cinteropCouchbaseLiteIos FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':shared:cinteropCouchbaseLiteIos'.
> Cannot perform cinterop processing for module CouchbaseLite: cannot determine headers location.

  Probably the build is executed from command line.
  Note that a Kotlin/Native module using CocoaPods dependencies can be built only from Xcode.

This is all running within Android Studio, so the error seems to indicate Xcode is required to build. Is this something the default cocoapods plugin now supports that your plugin does not?

We can use the default cocoapods plugin, now that we've gotten it working there. Although, I was interested in the option to export the API for KLib libraries in the framework, as described in your Kermit log library, which isn't an option with the default plugin, as far as I'm aware.