Why it occurs
Once you create a KMP undertaking with Compose Multiplatform, the shared code (together with the Compose UI) is compiled into an iOS framework (often referred to as shared.framework or one thing related) that must be imported into your Xcode undertaking.
If the Xcode undertaking isn’t pointing to the fitting output folder or hasn’t constructed the framework but, Swift will say:
No such module 'ComposeApp'
Steps to repair it
-
Make sure the iOS framework is constructed
-
In Android Studio (or by way of terminal), run:
./gradlew :shared:packForXcodeor in case your module is known as in another way:
./gradlew :composeApp:syncFrameworkThis activity generates the
.frameworkfile inshared/construct/XCFrameworks.
-
-
Test your Xcode undertaking setup
-
In your iOS app’s Xcode undertaking, go to Frameworks, Libraries, and Embedded Content material and ensure the generated
ComposeApp.xcframework(or no matter it’s named) is added. -
If it’s lacking, drag it from the Gradle construct output folder into Xcode.
-
-
Replace the import path
-
In your Swift code, import it precisely because the framework is known as — if the framework is
shared, you’ll use:import sharedIn case your KMP undertaking named it
ComposeApp, then:import ComposeApp
-
-
Re-sync Gradle and Xcode
-
Typically adjustments don’t mirror till you clear and rebuild:
./gradlew clear ./gradlew :shared:packForXcodeThen in Xcode: Product → Clear Construct Folder and rebuild.
-
-
Match the iOS goal
-
Be certain that the Gradle construct is creating the framework for a similar structure your simulator or machine makes use of (
arm64for gadgets,x86_64for Intel simulators,arm64for Apple Silicon simulators). -
For those who run into structure mismatches, you may specify:
./gradlew :shared:packForXcode -Pkotlin.native.cocoapods.goal=iosSimulatorArm64
-
