moko-resources icon indicating copy to clipboard operation
moko-resources copied to clipboard

Expected function 'getPlatform' has no actual declaration in module Mymodule:shared for Native

Open manjukumari1 opened this issue 1 year ago • 1 comments

error: Expected function 'getPlatform' has no actual declaration in module ComposeMuliplatformApp:shared for Native error: Compilation finished with errors FAILURE: Build failed with an exception.

What went wrong: Execution failed for task ':shared:compileKotlinIosSimulatorArm64'. Compilation finished with errors

For configuration I have added below things inside shared build.gradle:

listOf( iosX64(), iosArm64(), iosSimulatorArm64() ).forEach { it.binaries.framework { baseName = "ComposeApp" isStatic = true export("dev.icerock.moko:resources:0.23.0") export("dev.icerock.moko:graphics:0.9.0") // toUIColor here } }

sourceSets { getByName("androidMain") { dependsOn(commonMain.get()) kotlin.srcDir("build/generated/moko/androidMain/src") } getByName("iosX64Main") { dependsOn(commonMain.get()) kotlin.srcDir("build/generated/moko/iosX64Main/src") } getByName("iosArm64Main") { dependsOn(commonMain.get()) kotlin.srcDir("build/generated/moko/iosArm64Main/src") } getByName("iosSimulatorArm64Main") { dependsOn(commonMain.get()) kotlin.srcDir("build/generated/moko/iosSimulatorArm64Main/src") } }

And with iosApp.xcworkspace added following script

"$SRCROOT/../gradlew" -p "$SRCROOT/../" :shared:copyFrameworkResourcesToApp -Pmoko.resources.PLATFORM_NAME="$PLATFORM_NAME" -Pmoko.resources.CONFIGURATION="$CONFIGURATION" -Pmoko.resources.ARCHS="$ARCHS" -Pmoko.resources.BUILT_PRODUCTS_DIR="$BUILT_PRODUCTS_DIR" -Pmoko.resources.CONTENTS_FOLDER_PATH="$CONTENTS_FOLDER_PATH"

manjukumari1 avatar Jan 21 '24 12:01 manjukumari1

Having the same issue. But I didn't add kotlin.srcDir("build/generated/moko/iosX64Main/src")

Neither I did anything with iosApp.xcworkspace

The problem appeared after connection moko-resources on my KMM compose project with shared UI

derynia avatar Jan 28 '24 17:01 derynia

Did you add the build phase like this to the iOS app?

"$SRCROOT/../gradlew" -p "$SRCROOT/../" :composeApp:copyFrameworkResourcesToApp \
    -Pmoko.resources.PLATFORM_NAME="$PLATFORM_NAME" \
    -Pmoko.resources.CONFIGURATION="$CONFIGURATION" \
    -Pmoko.resources.ARCHS="$ARCHS" \
    -Pmoko.resources.BUILT_PRODUCTS_DIR="$BUILT_PRODUCTS_DIR" \
    -Pmoko.resources.CONTENTS_FOLDER_PATH="$CONTENTS_FOLDER_PATH"

It's in the documentation as well:

https://github.com/icerockdev/moko-resources

PRobi23 avatar Mar 07 '24 13:03 PRobi23

Please, read Readme, i'm agree with @PRobi23. For Apple projects you need add copy script in build phase.

ExNDY avatar Apr 21 '24 01:04 ExNDY