Skip to content

Avoiding PackForXcode task and using cocoapods instead #149

@Stegnerd

Description

@Stegnerd

When you create a new kotlin kmm project as it is today, in the shared module there is a task

val packForXcode by tasks.creating(Sync::class) {
    group = "build"
    val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
    val sdkName = System.getenv("SDK_NAME") ?: "iphonesimulator"
    val targetName = "ios" + if (sdkName.startsWith("iphoneos")) "Arm64" else "X64"
    val framework = kotlin.targets.getByName<KotlinNativeTarget>(targetName).binaries.getFramework(mode)
    inputs.property("mode", mode)
    dependsOn(framework.linkTask)
    val targetDir = File(buildDir, "xcode-frameworks")
    from({ framework.outputDirectory })
    into(targetDir)
}

tasks.getByName("build").dependsOn(packForXcode)

I looked high and low in this repo and its commit history and I never saw this here. I understand using the cocoapods and pod file in the ios project. I was able to generate those same files in my own project. However when I delete the generated task above I get the following error:

Task 'packForXCode' not found in project ':shared'.

I read through the docs of following:
https://github.com/touchlab/KotlinCocoapods
https://github.com/touchlab/KaMPKit/blob/master/docs/IOS_PROJ_INTEGRATION.md

at first I thought it was due to not using: cocoapodsext in the build file but I found a similar repo : https://github.com/joreilly/PeopleInSpace/blob/master/common/build.gradle.kts that manages to do the same logic with the native plugin. I tried looking through the gradle tasks as well and I saw no discernible difference in that regard we well.

I was wondering if you could explain how you came to implement something like this from a purely learning perspective? What were the reasons you implemented this was as opposed the generated task mentioned above?

Thanks for taking the time to read this/ answer my questions!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions