Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
manjukumari1 opened this issue Jan 21, 2024 · 3 comments

Comments

@manjukumari1
Copy link

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"

@derynia
Copy link

derynia commented Jan 28, 2024

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

@PRobi23
Copy link

PRobi23 commented Mar 7, 2024

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

@ExNDY
Copy link
Contributor

ExNDY commented Apr 21, 2024

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

@ExNDY ExNDY closed this as completed Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants