gradle / gradle-native

The home of Gradle's support for natively compiled languages
https://blog.gradle.org/introducing-the-new-cpp-plugins
Apache License 2.0
91 stars 8 forks source link

Demonstrate cocoapods integration #1033

Open lacasseio opened 4 years ago

lacasseio commented 4 years ago

The cocoapods integration should be very similar to prebuilt binaries. The exception would be around the Xcode integration that Cocoapods depends.

We would need to evaluate to know if the presence of the dependency project in Xcode is required for development or only for building. In the even the Cocoapod Xcode project are only useful to the developer for code browsing, then we should consider aligning with the same concept for other types of dependencies.

acecilia commented 4 years ago

Hello @lacasseio:

Can you elaborate a bit more on what you mentioned?

I am trying to find information about how to generate a gradle build from a pod, but could not find much. Usually, pods are hosted on a repository, with a podspec file at root level. Seems like what needs to be done is to generate a source dependency gradle build from a podspec file, so other gradle projects can consume it. Is this supported? Is there any plugin supporting it?

Thanks!

lacasseio commented 4 years ago

With the current feature set of Gradle, it should be possible to consume or even produce compatible Cocoapod modules. It would require quite a bit of work but we would prefer demonstrating how it looks with the current feature sets before heading toward adding extra feature to Gradle. There may be features that not only Cocoapod integration could benefit from which is where we would rather focus our energy. We can work together to create such demonstration which you could then use in your projects if you want.

acecilia commented 4 years ago

I see, thanks for the answer. I am not familiar with gradle, just started looking into it as an alternative to buck and bazel.

Would it be possible for you to provide some information about how you think the current set of features can be used to consume a pod? I am having difficulties understanding which of the current plugins/rules are the ones to be used for this.

lacasseio commented 4 years ago

The main concept here is to "expose" the binaries you need from Cocoapod to Gradle together with the how to build/download them to Gradle. Gradle's dependency engine is the key for the integration. You can see an example of how the native plugins use the dependency engine inside the build-wrapper-plugin inside the gradle/native-samples repository.

What would most likely have to be done is creating a plugin that would have a minimum configuration to tell what Cocoapod module you want. Then, the plugin could create the tasks required to pull the module via pods by writing a custom Podfile then it could build the Xcode workspace via xcodebuild and then expose the binaries through the dependency engine. Another project using C++ or Swift plugins for example, would have to declare a dependency on the project via normal dependency configuration. The end result would look a bit like the build-wrapper-plugin which can be a good starting point.