Difference between framework generated from packForXcode task and Cocoapods plugin

Hello,
I’m working with Kotlin multiplatform project, I want to know the limitations to create a framework from gradle task like:
image

and create using Cocoapods. Which one is the best?

What’s the main difference between them and what is the pros and cons?
Other question is: Can I use Generics in my swift code, importing a pod library from Kotlin? When I create a framework from packForXcode task, I used the command freeCompilerArgs += “-Xobjc-generics”:

image

How can I do it using CocoaPods? Is there any command that does this, to put on cocoapods extension in my gradle file?

3 Likes

Hello, @rshigenari.1! Both approaches are good enough IMHO, cocoaPods plugins’ pros are

  1. more laconic declaratiton, and
  2. ability to interoperate with frameworks distributed via cocoaPods with no hand-written .def files.
    On the other side, when you use your own Gradle task, you can easier just it for some specific needs - copying resources, etc.
    About using -Xobjc-generics flag. It can be set using kotlinOptions property of the compilation, see .kts example below:
ios {
    compilations {
        val main by getting {
            kotlinOptions.freeCompilerArgs = listOf("-Xobjc-generics")
        }
    }
1 Like