jcraane / kmm-images

Gradle plugin for using images in all targets in a Kotlin multiplatform project
Apache License 2.0
30 stars 6 forks source link

embedAndSignAppleFrameworkForXcode #11

Closed moffpage closed 3 years ago

moffpage commented 3 years ago

Hi! I use your plugin to have the access to icons in commonMain. In the documentation it is said that we have to make sure the resources are copied into the framework by adding some code into the doLast subtask inside packForXcode Gradle task. Could you please provide updated info if we use new embedAndSignAppleFrameworkForXcode task instead? Should we just generate frameworks the old way or is there any possibility to extend it so that we could ensure resources are copied during framework creation?

jcraane commented 3 years ago

Thanks for posting. I am going to look into this about how this is done with the embedAndSignAppleFrameworkForXcode task.

jcraane commented 3 years ago

Working on it.

jcraane commented 3 years ago

I might have a first working solution by utilizing the link* tasks, see the below example. You might need to set the correct paths. The CONFIGURATION and SDK_NAME are set by Xcode. You might also apply the same logic for the linkReleaseFrameworkIos (the example uses the linkDebugFrameworkIos task).

I will update the docs of this plugin with this new information after I do some more testing. No new release of the plugin is required.

tasks {
    named("compileKotlinIos") {
        dependsOn(generateImages)
    }

    named("linkDebugFrameworkIos") {
        doFirst {
            val configuration = System.getenv("CONFIGURATION")
            val sdkName = System.getenv("SDK_NAME")

            copy {
                from("${project.rootDir}/shared/src/commonMain/resources/ios")
                into("${project.buildDir}/xcode-frameworks/$configuration/$sdkName/shared.framework")
            }
        }
    }
}
moffpage commented 3 years ago

That's great! Thanks for help.