JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.03k stars 1.16k forks source link

iOS Add Compose to existing iOS project #3505

Closed onseok closed 1 week ago

onseok commented 1 year ago

Describe the bug After adding pod("FirebaseAnalytics", "~> 10.13") to the shared build.gradle.kts cocoapods block, the iOS app fails to run. The iOS application can no longer recognize the shared module. Just like this.

error: cannot find 'AppModuleKt' in scope
        AppModuleKt.doInitKoin()
        ^~~~~~~~~~~

error: cannot find 'NapierProxyKt' in scope
        NapierProxyKt.debugBuild()
        ^~~~~~~~~~~~~

Interestingly, when the pod("FirebaseAnalytics") { version = "~> 10.13" } block is commented out and run iosApp is executed, the application runs without any issues. The exact cause of this behavior remains unclear.

Affected platforms

Versions

Screenshots

image image

And this is gradle.properties

image
vinceglb commented 1 year ago

I had a problem similar to yours some time ago.

This is not a problem due to Compose Multiplatform. This is probably due to the version of Xcode you are using.

FirebaseAnalytics uses an old API that is not supported anymore in the new Xcode versions.

Try downgrading Xcode version to something like 14.0 and retry to build your project.

Read more here: https://kotlinlang.slack.com/archives/C9JM6Q2UX/p1686842942651169

mazunin-v-jb commented 1 year ago

Hello! Thanks for submitting the issue. My reproducer works fine. (Similar project versions to yours, Xcode version is Version 14.3.1 (14E300c)) Could you please create a minimal reproducer and tell what is your Xcode version? It will be helpful for understanding the problem.

Also, try to check with a lower version of Xcode. This also possibly could be a cause of this behavior.

onseok commented 1 year ago

Thank you for your response. My Xcode version was also 14.3.1 (14E300c), and the reproducer project from @mazunin-v-jb worked well for me too.

Upon further inspection, I realized that the issue arose after adding the run script to Xcode's Build Phases, as suggested in this tutorial: connect-the-framework-to-your-ios-project

Here's the script I added:

# Type a script or drag a script file from your workspace to insert its path.
cd "$SRCROOT/.."
./gradlew :shared:embedAndSignAppleFrameworkForXcode

After removing this run script, everything started working fine again.

mazunin-v-jb commented 1 year ago

Thank you for providing information. Unfortunately, for now we are currently not providing a convenient way to connect Compose to existing Xcode projects. We want to add a tutorial and samples for those cases later. Please stay tuned.

For now, I can only recommend you to ask questions in the compose-ios Slack channel.

okushnikov commented 1 month ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.