https://kotlinlang.org logo
n

nestserau

02/26/2019, 4:38 PM
A question about publishing fat iOS frameworks to a Maven repository. So I can successfully publish Android artifacts to a Maven repository (namely, Archiva). I need to also add iOS debug and release fat frameworks to the list of artifacts along with the already published
klib
under the
ios
category. I build my fat frameworks using this code: https://gist.github.com/benasher44/32f602b9d5ec596ceaa3c9d190b14fc9 Kudos to @basher Further I’ve added a couple of extra tasks to create a zip to be consumed by CocoaPods:
Copy code
task("zipIos${config}Artifacts", dependsOn: "createIos${config}Artifacts", group: "iOS", type: Zip) {
            archiveFileName = "${rootProject.name}${"debug".equalsIgnoreCase(config) ? '-debug' : ''}.zip"
            destinationDirectory = file("$outputDir/..")
            from outputDir
        }
And now I’m stuck. How do I tell the
maven-publish
plugin to also include the artifacts produced by
zipIosDebugArtifacts
and
zipIosReleaseArtifacts
tasks? If I read these docs https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#publishing-a-multiplatform-library it concerns configuring targets, but that’s not something that is useful for me, since my artifact is a result of multiple targets.
I’ll answer my question for someone who will find it in the future. Publishing the framework to a Maven repo was pretty easy actually. I had to add this:
Copy code
publishing {
    repositories {
        maven {
            url "yourUrl"
            credentials(PasswordCredentials) {
                username = 'username'
                password = 'password'
            }
        }
    }
    publications {
        iosDebugFrameworks(MavenPublication) {
            afterEvaluate {
                artifactId = 'reports-framework-debug'
                artifact zipIosDebugArtifacts
            }
        }
        iosReleaseFrameworks(MavenPublication) {
            afterEvaluate {
                artifactId = 'reports-framework'
                artifact zipIosReleaseArtifacts
            }
        }
    }
}
And on top of that you need to move the code in the original post from
afterEvaluate
to the main body. It requires very minimal adjustments, so there is no good reason for it to be in
afterEvaluate
actually.
🙌 1
2 Views