Why it occurs
While you create a KMP mission with Compose Multiplatform, the shared code (together with the Compose UI) is compiled into an iOS framework (normally referred to as shared.framework
or one thing related) that must be imported into your Xcode mission.
If the Xcode mission isn’t pointing to the best 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 through terminal), run:
./gradlew :shared:packForXcode
or in case your module is known as in a different way:
./gradlew :composeApp:syncFramework
This activity generates the
.framework
file inshared/construct/XCFrameworks
.
-
-
Test your Xcode mission setup
-
In your iOS app’s Xcode mission, 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 shared
In case your KMP mission named it
ComposeApp
, then:import ComposeApp
-
-
Re-sync Gradle and Xcode
-
Generally adjustments don’t mirror till you clear and rebuild:
./gradlew clear ./gradlew :shared:packForXcode
Then in Xcode: Product → Clear Construct Folder and rebuild.
-
-
Match the iOS goal
-
Make sure that the Gradle construct is creating the framework for a similar structure your simulator or machine makes use of (
arm64
for units,x86_64
for Intel simulators,arm64
for Apple Silicon simulators). -
In case you run into structure mismatches, you’ll be able to specify:
./gradlew :shared:packForXcode -Pkotlin.native.cocoapods.goal=iosSimulatorArm64
-