ge-org / multiplatform-swiftpackage

Gradle plugin that generates a Swift Package Manager manifest and an XCFramework to distribute a Kotlin Multiplatform library for Apple platforms.
Apache License 2.0
336 stars 49 forks source link

Enable Customization of Package Name #5

Closed JUSTINMKAUFMAN closed 3 years ago

JUSTINMKAUFMAN commented 3 years ago

First of all, great work on this plugin! I expect it will grow in popularity as SPM and XCFrameworks become more ubiquitous in the coming months.

This PR proposes to add an interface to allow the customization of the frameworkName. The result offers similar functionality to the KMP cocoapods plugin (which also allows configuration of this property).

Because Apple-platform framework names tend not to follow the same naming conventions as their Kotlin/Java counterparts, this will help folks (such as myself) avoid:

import my_kotlin_library

...and instead do:

import MyKotlinLibrary

Let me know what you think, and thanks again for making this library!

ge-org commented 3 years ago

Hi @JUSTINMKAUFMAN ,

thanks again for you contribution and feedback. I did some research and looked into the cocoapods plugin code to see how they are doing it. And it turns out they use the base name of the framework as the name of the package. So I added 7d107d5cae9abd8a7566c05b115698b62ae091dd which basically does the same now. By default it uses the base name of the first framework in the project as the name of the package. It also adds a configuration option that allows to overwrite the name of the package.

Does this solve your requirement? I'll also start working on a PR now that allows to overwrite the framework name (aka. base name).

To configure the base name, either use the cocoapods plugin or the plain KMP plugin:

// with cocoapods
cocoapods {
  summary = "Some description for a Kotlin/Native module"
  homepage = "Link to a Kotlin/Native module homepage"

  // this will be the name of the Swift package
  frameworkName = "MyFramework"
}

// with KMP
ios("ios") {
    binaries {
        framework {
            // this will be the name of the Swift package
            baseName = "MyKit"
        }
    }
}
ge-org commented 3 years ago

Dang you macBook keyboard! Key was stuck and closed the PR 🙄

JUSTINMKAUFMAN commented 3 years ago

Hi @JUSTINMKAUFMAN ,

thanks again for you contribution and feedback. I did some research and looked into the cocoapods plugin code to see how they are doing it.

And it turns out they use the base name of the framework as the name of the package. So I added 7d107d5cae9abd8a7566c05b115698b62ae091dd which basically does the same now. By default it uses the base name of the first framework in the project as the name of the package. It also adds a configuration option that allows to overwrite the name of the package.

Does this solve your requirement?

I'll also start working on a PR now that allows to overwrite the framework name (aka. base name).

To configure the base name, either use the cocoapods plugin or the plain KMP plugin:


// with cocoapods

cocoapods {

  summary = "Some description for a Kotlin/Native module"

  homepage = "Link to a Kotlin/Native module homepage"

  // this will be the name of the Swift package

  frameworkName = "MyFramework"

}

// with KMP

ios("ios") {

    binaries {

        framework {

            // this will be the name of the Swift package

            baseName = "MyKit"

        }

    }

}

This is perfect! Thanks for the quick review and further edits.