Why it happens
When you create a KMP project with Compose Multiplatform, the shared code (including the Compose UI) is compiled into an iOS framework (usually called shared.framework
or something similar) that needs to be imported into your Xcode project.
If the Xcode project isn’t pointing to the right output folder or hasn’t built the framework yet, Swift will say:
No such module 'ComposeApp'
Steps to fix it
-
Ensure the iOS framework is built
-
In Android Studio (or via terminal), run:
./gradlew :shared:packForXcode
or if your module is named differently:
./gradlew :composeApp:syncFramework
This task generates the
.framework
file inshared/build/XCFrameworks
.
-
-
Check your Xcode project setup
-
In your iOS app’s Xcode project, go to Frameworks, Libraries, and Embedded Content and make sure the generated
ComposeApp.xcframework
(or whatever it’s named) is added. -
If it’s missing, drag it from the Gradle build output folder into Xcode.
-
-
Update the import path
-
In your Swift code, import it exactly as the framework is named — if the framework is
shared
, you would use:import shared
If your KMP project named it
ComposeApp
, then:import ComposeApp
-
-
Re-sync Gradle and Xcode
-
Sometimes changes don’t reflect until you clean and rebuild:
./gradlew clean ./gradlew :shared:packForXcode
Then in Xcode: Product → Clean Build Folder and rebuild.
-
-
Match the iOS target
-
Make sure the Gradle build is creating the framework for the same architecture your simulator or device uses (
arm64
for devices,x86_64
for Intel simulators,arm64
for Apple Silicon simulators). -
If you run into architecture mismatches, you can specify:
./gradlew :shared:packForXcode -Pkotlin.native.cocoapods.target=iosSimulatorArm64
-