{"slug":"kmp-feature-module","title":"kmp-feature-module","summary":"Use when adding a new feature or library module to a Kotlin Multiplatform project - \"create a module\", \"modularize this feature\", a :feature module, settings.gradle.kts include lines, a logic/ui module split so SwiftUI can consume shared logic, an umbrella shared iOS framework, e","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-12-03T17:29:50.315905Z","repo":{"url":"https://github.com/Kushpawan/kmp-mobile-skills","stars":17,"forks":2,"license":"Apache-2.0","updatedAt":"2026-12-03T13:18:24Z"},"bodyHtml":"<hr>\n<h2>name: kmp-feature-module\ndescription: Use when adding a new feature or library module to a Kotlin Multiplatform project - \"create a module\", \"modularize this feature\", a :feature module, settings.gradle.kts include lines, a logic/ui module split so SwiftUI can consume shared logic, an umbrella shared iOS framework, export() to Swift, com.android.kotlin.multiplatform.library and its android target block (withHostTest, androidResources), or a new module that builds on Android while Swift reports \"Cannot find 'X' in scope\". Not for moving existing modules to AGP 9.\nlicense: Apache-2.0\ncompatibility: Kotlin Multiplatform Gradle project. Default templates target AGP 9.x with the Android-KMP library plugin and Kotlin 2.5; older layouts (AGP 8.10+, androidTarget) are followed when the project uses them. iOS framework checks need macOS with Xcode. Checked December 2026.\nmetadata:\ncategory: build\nplatforms: android, ios</h2>\n<h1>KMP feature module</h1>\n<p>A feature module is a Gradle project with one owner, a narrow public API, and exactly two ways in:\nthe app's DI graph and the app's navigation host. Pick the module shape the project already uses.\nThe most expensive mistake is a module that builds and runs on Android while the iOS framework\nsilently does not contain it.</p>\n<h2>When to use</h2>\n<ul>\n<li>Creating <code>:feature:&lt;name&gt;</code> or a reusable library module in a KMP build.</li>\n<li>Splitting a feature out of a monolithic <code>:shared</code> or <code>:composeApp</code>.</li>\n<li>Adding a <code>:logic</code> + <code>:ui</code> pair for an app whose iOS UI is SwiftUI.</li>\n<li>A new module compiles for Android but its types are missing in Swift.</li>\n</ul>\n<h2>When not to use</h2>\n<ul>\n<li>Adding a platform API inside an existing module: use <code>kmp-expect-actual</code>.</li>\n<li>Adding or upgrading a dependency or Gradle plugin: use <code>kmp-gradle-version-catalog</code>.</li>\n<li>Auditing an existing module: use <code>kmp-module-health</code>.</li>\n<li>Migrating existing modules to AGP 9 (<code>androidTarget()</code> to the Android-KMP library plugin, splitting\nthe app entry point out): use JetBrains'\n<a href=\"https://github.com/Kotlin/kotlin-agent-skills/tree/main/skills/kotlin-tooling-agp9-migration\"><code>kotlin-tooling-agp9-migration</code></a>.</li>\n<li>Turning an Android-only app into KMP: use <code>android-to-kmp-migration</code>.</li>\n</ul>\n<h2>Step 0 — Read the project first</h2>\n<p>Do not write a build file from memory. Read the build, record the answers, then copy the closest\nexisting sibling module.</p>\n<pre><code>cat settings.gradle.kts                                        # include(...), includeBuild, catalog path\nfind . -name build.gradle.kts -not -path '*/build/*' | sort    # existing modules\ngrep -nE '^(agp|kotlin|composeMultiplatform|android-?[Gg]radle[A-Za-z-]*) *=' gradle/libs.versions.toml\ngrep -rnE 'androidTarget\\(|androidLibrary *\\{|kotlin\\.multiplatform\\.library|com\\.android\\.library' \\\n  --include=build.gradle.kts .                                 # which Android-target style siblings use\ngrep -rln \"binaries.framework\" --include=build.gradle.kts .     # who produces the iOS framework\ngrep -rn  \"export(\" --include=build.gradle.kts .                # what Swift can see today (Obj-C framework)\ngrep -rnE \"swift *\\{|swiftExport\" --include=build.gradle.kts .  # Swift export instead of a framework?\ngrep -rlE \"composeMultiplatform|org.jetbrains.compose\" --include=build.gradle.kts .\nls build-logic buildSrc 2&gt;/dev/null                            # convention plugins\ngrep -rl \"ComposeUIViewController\" --include='*.kt' . | head -3  # iOS renders Compose?\n</code></pre>\n<table>\n<thead>\n<tr>\n<th>Record</th>\n<th>Where it shows up</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Module naming (<code>:feature:notes</code>, <code>:notes</code>, <code>:features:notes-impl</code>)</td>\n<td><code>include(...)</code> lines</td>\n</tr>\n<tr>\n<td>Kotlin and AGP versions</td>\n<td><code>gradle/libs.versions.toml</code></td>\n</tr>\n<tr>\n<td>Android target style: <code>com.android.kotlin.multiplatform.library</code> + <code>kotlin { android { } }</code> (current), <code>kotlin { androidLibrary { } }</code> (deprecated since AGP 9.1.0-alpha09), or <code>com.android.library</code> + <code>androidTarget()</code> (legacy)</td>\n<td>sibling build files</td>\n</tr>\n<tr>\n<td>Swift interop: Objective-C framework (<code>binaries.framework</code> + <code>export(...)</code>) or Swift export (<code>export { swift { } }</code>)</td>\n<td>the module iOS links</td>\n</tr>\n<tr>\n<td>iOS targets: <code>iosArm64</code>, <code>iosSimulatorArm64</code>, maybe <code>iosX64</code></td>\n<td>sibling build files — a new module declares the same set as its consumers</td>\n</tr>\n<tr>\n<td>Convention plugins (<code>id(\"com.example.kmp.library\")</code>)</td>\n<td><code>build-logic/</code>, <code>buildSrc/</code></td>\n</tr>\n<tr>\n<td>DI: Koin, kotlin-inject, Metro, manual</td>\n<td><code>startKoin</code>, <code>@Component</code></td>\n</tr>\n<tr>\n<td>Navigation: Navigation Compose, Navigation 3, Decompose, Voyager</td>\n<td>the <code>NavHost</code> or root component</td>\n</tr>\n<tr>\n<td>Presentation: <code>ViewModel</code> + <code>StateFlow</code>, or an MVI base such as <code>MviViewModel&lt;State, Effect&gt;</code></td>\n<td>existing ViewModels</td>\n</tr>\n<tr>\n<td>Package root, test naming, fakes vs mocks</td>\n<td>an existing module's <code>commonTest</code></td>\n</tr>\n</tbody>\n</table>\n<p>Then choose the shape:</p>\n<table>\n<thead>\n<tr>\n<th>What you find</th>\n<th>Shape</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>The framework module applies Compose and iOS shows <code>ComposeUIViewController</code></td>\n<td><strong>A — shared Compose UI.</strong> Screens live in <code>commonMain</code> of the feature module.</td>\n</tr>\n<tr>\n<td>iOS UI is SwiftUI; the framework module has no Compose; features come as <code>:logic</code>/<code>:ui</code> (or <code>api</code>/<code>impl</code>, <code>domain</code>/<code>presentation</code>) pairs</td>\n<td><strong>B — logic/ui split.</strong> <code>:logic</code> is KMP without Compose; <code>:ui</code> is Compose for Android.</td>\n</tr>\n<tr>\n<td>One monolithic <code>:shared</code> with a package per feature and no feature modules</td>\n<td><strong>Ask.</strong> Default to a new package inside <code>:shared</code>. Do not modularize as a side effect.</td>\n</tr>\n<tr>\n<td>Greenfield</td>\n<td>A if iOS will render Compose Multiplatform; B if iOS will be native SwiftUI.</td>\n</tr>\n</tbody>\n</table>\n<p>Write down the choice. Every later step follows it.</p>\n<h2>Workflow</h2>\n<h3>1. Name the module</h3>\n<table>\n<thead>\n<tr>\n<th></th>\n<th>Shape A</th>\n<th>Shape B</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Gradle path</td>\n<td><code>:feature:notes</code></td>\n<td><code>:feature:notes:logic</code>, <code>:feature:notes:ui</code></td>\n</tr>\n<tr>\n<td>Directory</td>\n<td><code>feature/notes/</code></td>\n<td><code>feature/notes/logic/</code>, <code>feature/notes/ui/</code></td>\n</tr>\n<tr>\n<td>Package</td>\n<td><code>com.example.app.feature.notes</code></td>\n<td><code>com.example.app.feature.notes</code> in both</td>\n</tr>\n<tr>\n<td>Android <code>namespace</code></td>\n<td><code>com.example.app.feature.notes</code></td>\n<td><code>…feature.notes.logic</code>, <code>…feature.notes.ui</code></td>\n</tr>\n</tbody>\n</table>\n<p>Every module needs a unique <code>namespace</code>. Duplicates collide in generated <code>R</code> classes, and AGP 9 fails\nthe build on them by default. Done when <code>grep -rn 'namespace = \"com.example.app.feature.notes' .</code>\nfinds nothing yet.</p>\n<h3>2. Register it in <code>settings.gradle.kts</code></h3>\n<pre><code>include(\":feature:notes\")                              // Shape A\ninclude(\":feature:notes:logic\", \":feature:notes:ui\")   // Shape B\n</code></pre>\n<p>Gradle maps <code>:feature:notes:logic</code> to <code>feature/notes/logic/</code> by default. If the build enables\n<code>TYPESAFE_PROJECT_ACCESSORS</code>, other modules may write <code>projects.feature.notes.logic</code>; follow what\nsiblings use. Done when <code>./gradlew projects</code> lists the new path.</p>\n<h3>3. Write the build file</h3>\n<p>If a convention plugin exists, the build file is a few lines: apply it, set <code>namespace</code>, add\ndependencies. Otherwise copy the matching template from\n<a href=\"references/gradle-templates.md\">references/gradle-templates.md</a>. Rules that apply either way:</p>\n<ul>\n<li><p><strong>Android target (default).</strong> Apply <code>com.android.kotlin.multiplatform.library</code> and put all Android\nconfig in <code>kotlin { android { } }</code>; there is no top-level <code>android { }</code> block. On AGP 8.12+ the\nblock is <code>android { }</code>; <code>androidLibrary { }</code> is deprecated since AGP 9.1.0-alpha09, so only an\nAGP 8.10–8.11 build uses it. Kotlin 2.5 deprecates <code>androidTarget()</code> with <code>com.android.library</code> on\nevery AGP version, and AGP 9 accepts it only behind legacy opt-outs. Use it in a new module <strong>only</strong>\nwhen every sibling still does (legacy, follow the project); migrate separately.</p>\n</li>\n<li><p><strong>Opt-ins on the Android-KMP plugin.</strong> Everything below is off by default, so a module that needs\nit must ask for it inside <code>kotlin { android { } }</code>:</p>\n<table>\n<thead>\n<tr>\n<th>Need</th>\n<th>DSL</th>\n<th>Without it</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Host (unit) tests in <code>src/androidHostTest</code></td>\n<td><code>withHostTest {}</code></td>\n<td><code>androidHostTest</code> never compiles or runs</td>\n</tr>\n<tr>\n<td>Device tests in <code>src/androidDeviceTest</code></td>\n<td><code>withDeviceTest { instrumentationRunner = \"androidx.test.runner.AndroidJUnitRunner\" }</code></td>\n<td>no instrumented test task</td>\n</tr>\n<tr>\n<td>Android <code>res/</code> (in <code>src/androidMain/res</code>) or Compose resources</td>\n<td><code>androidResources { enable = true }</code></td>\n<td>Compose resources fail at runtime</td>\n</tr>\n<tr>\n<td>Java sources in <code>androidMain</code></td>\n<td><code>withJava()</code></td>\n<td>Java sources are not compiled</td>\n</tr>\n<tr>\n<td>Consumer R8 keep rules</td>\n<td><code>optimization { consumerKeepRules.apply { publish = true; file(\"consumer-rules.pro\") } }</code></td>\n<td>rules are not shipped to the app</td>\n</tr>\n</tbody>\n</table>\n</li>\n<li><p><strong>No variants.</strong> The plugin has one variant: no build types, flavours or <code>BuildConfig</code>. Pass\nconfiguration in from the app through DI. Compose tooling for previews goes on\n<code>\"androidRuntimeClasspath\"(...)</code> in the top-level <code>dependencies { }</code>, not <code>debugImplementation</code>\n(AGP 9.0.0-beta01+).</p>\n</li>\n<li><p><strong>iOS targets.</strong> Declare at least every target of each module that will depend on this one. A\nconsumer with <code>iosX64()</code> cannot depend on a module without it. <code>iosX64</code> is only for Intel-Mac simulators and is a Tier 3 target\nin current Kotlin (see the <a href=\"https://kotlinlang.org/docs/native-target-support.html\">target support page</a>).</p>\n</li>\n<li><p><strong>Frameworks.</strong> Feature modules declare no <code>binaries.framework</code>. Only the module iOS links (the\numbrella in Shape B, <code>:shared</code> or <code>:composeApp</code> in Shape A) produces one.</p>\n</li>\n<li><p><strong>Shape B <code>:logic</code> has no Compose.</strong> No Compose plugins, no Compose artifacts, not even through an\n<code>api</code> dependency. Compose there drags the Compose runtime into the iOS framework and puts types\nin its API that SwiftUI cannot use.</p>\n</li>\n<li><p><strong>Versions.</strong> Only <code>libs.*</code> accessors. New entries go through <code>kmp-gradle-version-catalog</code>.</p>\n</li>\n</ul>\n<p>Done when <code>./gradlew :feature:notes:help</code> (or <code>:feature:notes:logic:help</code>) configures without error.</p>\n<h3>4. Lay out the sources</h3>\n<pre><code>Shape A  feature/notes/src/\n  commonMain/kotlin/com/example/app/feature/notes/\n    data/  domain/  ui/ (NotesListScreen.kt, NotesListViewModel.kt)  navigation/  di/NotesModule.kt\n  commonTest/kotlin/com/example/app/feature/notes/\n  androidMain/  iosMain/            # only when an actual or platform binding is needed\n\nShape B  feature/notes/logic/src/commonMain/kotlin/com/example/app/feature/notes/\n    data/  domain/  presentation/ (NotesListViewModel.kt, NotesListState.kt)  di/NotesModule.kt\n         feature/notes/logic/src/commonTest/...\n         feature/notes/ui/src/commonMain/kotlin/com/example/app/feature/notes/\n    ui/ (NotesListScreen.kt, NotesListTestTags.kt)  navigation/NotesNavigation.kt  di/NotesUiModule.kt\n</code></pre>\n<p>Mirror the package layout of the nearest existing feature. Add <code>data/</code> and <code>domain/</code> only when the\nfeature has them; a screen that only navigates needs neither.</p>\n<h3>5. Add the DI module</h3>\n<p>Each feature exposes one DI module and registers nothing globally. Koin example:</p>\n<pre><code>// feature/notes/logic/src/commonMain/kotlin/com/example/app/feature/notes/di/NotesModule.kt\nval notesModule = module {\n    singleOf(::NotesRepositoryImpl) bind NotesRepository::class\n    factoryOf(::ObserveNotesUseCase)\n    viewModelOf(::NotesListViewModel)   // org.koin.core.module.dsl, from koin-core-viewmodel\n}\n</code></pre>\n<p>Register it where the app builds its graph — <code>startKoin { modules(appModule, notesModule) }</code> or an\naggregating <code>module { includes(notesModule) }</code>. In Shape B the iOS app starts the same graph through\nthe umbrella; see <a href=\"references/ios-umbrella-framework.md\">references/ios-umbrella-framework.md</a>.\nDone when the app module lists <code>notesModule</code>. A missing registration is a runtime\n<code>NoDefinitionFoundException</code>, not a compile error, so check it now.</p>\n<h3>6. Register navigation</h3>\n<p>The feature owns its destinations; the host adds one line per feature. Cross-feature navigation goes\nthrough callbacks that the app wires, never through another feature's route type.</p>\n<pre><code>// Shape A: feature module. Shape B: the :ui module.\n@Serializable data object NotesListRoute\n@Serializable data class NoteDetailRoute(val noteId: String)\n\nfun NavGraphBuilder.notesGraph(navController: NavController, onOpenProfile: () -&gt; Unit) {\n    composable&lt;NotesListRoute&gt; {\n        NotesListScreen(\n            onNoteClick = { noteId -&gt; navController.navigate(NoteDetailRoute(noteId)) },\n            onProfileClick = onOpenProfile,\n        )\n    }\n    composable&lt;NoteDetailRoute&gt; { NoteDetailScreen(onBack = { navController.popBackStack() }) }\n}\n\n// App NavHost — the only place that knows two features exist.\nNavHost(navController = navController, startDestination = NotesListRoute) {\n    notesGraph(navController = navController, onOpenProfile = { navController.navigate(ProfileRoute) })\n    profileGraph(navController = navController)\n}\n</code></pre>\n<p>If the project uses Navigation 3, Decompose or Voyager, follow its existing registration pattern\ninstead; the callback rule still holds. Done when the host compiles with the new line.</p>\n<h3>7. Wire it into its consumers</h3>\n<p><strong>Shape A.</strong> The module that owns the <code>NavHost</code> and the DI graph adds\n<code>implementation(project(\":feature:notes\"))</code>. If iOS only reaches the feature through Compose, no\n<code>export</code> is needed; export only what Swift calls directly.</p>\n<p><strong>Shape B.</strong> Two consumers, and the umbrella needs <strong>both</strong> lines:</p>\n<pre><code>// shared/build.gradle.kts — the umbrella that produces the iOS framework\nkotlin {\n    listOf(iosArm64(), iosSimulatorArm64()).forEach { target -&gt;\n        target.binaries.framework {\n            baseName = \"Shared\"\n            export(project(\":feature:notes:logic\"))   // puts its public API in the Swift header\n        }\n    }\n    sourceSets {\n        commonMain.dependencies {\n            api(project(\":feature:notes:logic\"))      // export() is legal only for api dependencies\n        }\n    }\n}\n</code></pre>\n<pre><code>// androidApp/build.gradle.kts\ndependencies { implementation(project(\":feature:notes:ui\")) }\n</code></pre>\n<p><code>export</code> without <code>api</code> fails the build. <code>api</code> without <code>export</code> is the silent failure: Android builds\nand runs, Gradle is green, and Swift later reports <code>Cannot find 'NotesListViewModel' in scope</code>.\n<code>export</code> is not transitive: if <code>NotesListViewModel</code> exposes <code>Note</code> from <code>:core:model</code>, export\n<code>:core:model</code> too. Done when the header check in <strong>Verify</strong> finds the class.</p>\n<p><strong>If the project uses Swift export</strong> (<code>export { swift { } }</code>, Beta in Kotlin 2.5.0, iOS 18+), there\nis no Objective-C header and no <code>export(...)</code> call. Each exported Gradle module becomes its own Swift\nmodule, and <code>api</code> dependencies of the linked module are exported automatically. A new <code>:logic</code>\nmodule is therefore a new Swift module: give it a stable name with <code>export { swift { moduleName = \"NotesLogic\" } }</code> in its own build file, and expect Swift call sites to import it by that name. Never\nlink a Swift export build and an Objective-C framework into the same Xcode target (two Kotlin\nruntimes). Setup and mappings: <code>kmp-swiftui-interop</code> and\n<a href=\"https://kotlinlang.org/docs/native-swift-export.html\">Swift export</a>.</p>\n<h3>8. Add the first test</h3>\n<p>Add one ViewModel or use-case test in <code>commonTest</code> using the project's test style (default\n<code>kotlin.test</code> + a hand-written fake + Turbine). A template is in\n<a href=\"references/gradle-templates.md#8-first-test\">references/gradle-templates.md</a>. Done when the test\nruns on both an Android and an iOS test task.</p>\n<h2>Rule: no feature depends on another feature</h2>\n<p>A feature-to-feature dependency couples release cycles, invites cycles, and lets one feature reach\ninto another's internals. Allowed edges:</p>\n<table>\n<thead>\n<tr>\n<th>From</th>\n<th>May depend on</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>:feature:notes:ui</code></td>\n<td><code>:feature:notes:logic</code>, <code>:core:*</code>, design system</td>\n</tr>\n<tr>\n<td><code>:feature:notes</code> / <code>:feature:notes:logic</code></td>\n<td><code>:core:*</code> (model, network, database, common)</td>\n</tr>\n<tr>\n<td><code>:core:*</code></td>\n<td>other <code>:core:*</code> only — never a feature, never the app</td>\n</tr>\n<tr>\n<td>App / umbrella</td>\n<td>every feature and <code>:core:*</code></td>\n</tr>\n</tbody>\n</table>\n<p>When two features must cooperate:</p>\n<ol>\n<li><strong>Navigation</strong> — callbacks wired by the app (step 6).</li>\n<li><strong>Shared data</strong> — move the type to a <code>:core:</code> module once a <em>second</em> feature needs it, not before.</li>\n<li><strong>Shared behaviour</strong> — declare an interface in a <code>:core:</code> module, implement it in the owning\nfeature, and bind it in the app's DI graph. The consuming feature sees only the interface.</li>\n</ol>\n<p>Check it from the root (expect no output; assumes modules under <code>feature/&lt;name&gt;/</code>):</p>\n<pre><code>for f in $(find feature -name build.gradle.kts -not -path '*/build/*'); do\n  own=$(echo \"$f\" | cut -d/ -f2)\n  grep -HnoE 'project\\(\":feature:[A-Za-z0-9_-]+|projects\\.feature\\.[A-Za-z0-9_]+' \"$f\" \\\n    | grep -vE \"(:feature:|projects\\.feature\\.)$own\\$\" || true\ndone\n</code></pre>\n<h2>Quick reference</h2>\n<table>\n<thead>\n<tr>\n<th>Task</th>\n<th>Shape A</th>\n<th>Shape B</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Plugins</td>\n<td>KMP, Android KMP library, Compose MP, Compose compiler</td>\n<td><code>:logic</code>: KMP, Android KMP library. <code>:ui</code>: plus Compose</td>\n</tr>\n<tr>\n<td>Android block</td>\n<td><code>kotlin { android { namespace; compileSdk; minSdk } }</code> + opt-ins it needs</td>\n<td>same in each module</td>\n</tr>\n<tr>\n<td>Preview tooling</td>\n<td><code>\"androidRuntimeClasspath\"(...)</code></td>\n<td>same, in <code>:ui</code></td>\n</tr>\n<tr>\n<td>iOS targets</td>\n<td>same as consumers</td>\n<td><code>:logic</code> only; <code>:ui</code> is Android-only</td>\n</tr>\n<tr>\n<td><code>binaries.framework</code></td>\n<td>no (unless iOS links this module)</td>\n<td>no; the umbrella has it</td>\n</tr>\n<tr>\n<td>Umbrella edits</td>\n<td>none, unless Swift calls it</td>\n<td><code>api(project(...))</code> <strong>and</strong> <code>export(project(...))</code> (Swift export: <code>api</code> only)</td>\n</tr>\n<tr>\n<td>Android app edit</td>\n<td>via the module that hosts the NavHost</td>\n<td><code>implementation(project(\":feature:&lt;name&gt;:ui\"))</code></td>\n</tr>\n<tr>\n<td>DI</td>\n<td><code>val &lt;name&gt;Module</code> registered in the app graph</td>\n<td>same, in <code>:logic</code>; UI-only bindings in <code>:ui</code></td>\n</tr>\n<tr>\n<td>Navigation</td>\n<td><code>NavGraphBuilder.&lt;name&gt;Graph(...)</code></td>\n<td>same, in <code>:ui</code></td>\n</tr>\n</tbody>\n</table>\n<h2>Verify</h2>\n<p>Run what applies and report each line as <code>PASS</code>, <code>FAIL</code> or <code>NOT RUN</code> (with the reason, e.g. \"no\nmacOS host\"). Never report a check as passed that you did not run. If a task name differs, list the\nreal ones with <code>./gradlew :feature:notes:logic:tasks --all | grep -iE 'compile|test|link'</code>.</p>\n<pre><code>./gradlew :feature:notes:logic:compileCommonMainKotlinMetadata      # shared code alone\n./gradlew :feature:notes:logic:compileAndroidMain                   # AGP KMP plugin (legacy: compileDebugKotlinAndroid)\n./gradlew :feature:notes:logic:compileKotlinIosSimulatorArm64       # macOS only\n./gradlew :feature:notes:logic:testAndroidHostTest                  # legacy plugin: testDebugUnitTest\n./gradlew :feature:notes:logic:iosSimulatorArm64Test                # macOS only\n./gradlew :shared:linkDebugFrameworkIosSimulatorArm64               # Shape B umbrella, macOS only\ngrep -c 'swift_name(\"NotesListViewModel\")' \\\n  shared/build/bin/iosSimulatorArm64/debugFramework/Shared.framework/Headers/Shared.h   # expect &gt;= 1\n# (Objective-C framework only; with Swift export, build the Xcode scheme and call the type from Swift)\n./gradlew :androidApp:assembleDebug                                 # or :composeApp:assembleDebug\n</code></pre>\n<p>Then run the feature-boundary check above, and build the iOS app in Xcode if a scheme exists.</p>\n<h2>Common mistakes</h2>\n<table>\n<thead>\n<tr>\n<th>Mistake</th>\n<th>Why it bites</th>\n<th>Fix</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>api(...)</code> in the umbrella but no <code>export(...)</code></td>\n<td>Android is fine; Swift cannot see the module, found late and far from the cause</td>\n<td>Add <code>export(project(...))</code> to every framework binary; run the header grep</td>\n</tr>\n<tr>\n<td>Exporting a module whose public types come from an un-exported module</td>\n<td><code>export</code> is not transitive; those types appear in Swift with module-prefixed names or not at all</td>\n<td>Export the type's own module too; avoid <code>transitiveExport = true</code> (size and link time)</td>\n</tr>\n<tr>\n<td>Compose dependency in a <code>:logic</code> module</td>\n<td>The SwiftUI-facing framework drags in Compose, or exposes Compose types Swift cannot use</td>\n<td>Keep Compose in <code>:ui</code>; put state the UI needs on the state class</td>\n</tr>\n<tr>\n<td>Feature imports another feature</td>\n<td>Coupled builds, cycles, internal APIs leak</td>\n<td>Callbacks, <code>:core:</code> types, or an interface bound by the app</td>\n</tr>\n<tr>\n<td>New module declares different iOS targets than its consumer</td>\n<td><code>No matching variant</code> / could not resolve for <code>iosX64</code> or similar</td>\n<td>Copy the target list from the consuming module</td>\n</tr>\n<tr>\n<td><code>binaries.framework</code> in every feature module</td>\n<td>Extra link tasks and framework files nobody ships</td>\n<td>Frameworks only where iOS links</td>\n</tr>\n<tr>\n<td>Two Kotlin frameworks linked into one iOS app</td>\n<td>Each carries its own Kotlin runtime; shared types are not the same type in Swift</td>\n<td>One umbrella framework per app</td>\n</tr>\n<tr>\n<td>New module on <code>androidTarget()</code> + <code>com.android.library</code> when siblings use the Android-KMP plugin</td>\n<td>Deprecated in Kotlin 2.5 on every AGP version; AGP 9 needs legacy opt-outs that AGP 10 removes</td>\n<td><code>com.android.kotlin.multiplatform.library</code> + <code>kotlin { android { } }</code></td>\n</tr>\n<tr>\n<td><code>androidLibrary { }</code> copied from an older guide</td>\n<td>Deprecated since AGP 9.1.0-alpha09; scheduled for removal</td>\n<td>Rename the block to <code>android { }</code> (AGP 8.12+)</td>\n</tr>\n<tr>\n<td>Forgot <code>withHostTest {}</code> with the AGP KMP plugin</td>\n<td><code>androidHostTest</code> sources silently never compile or run</td>\n<td>Enable host tests in <code>kotlin { android { } }</code></td>\n</tr>\n<tr>\n<td>Compose resources without <code>androidResources { enable = true }</code></td>\n<td>Builds, then fails at runtime on Android</td>\n<td>Enable Android resources in that module</td>\n</tr>\n<tr>\n<td>Reading <code>BuildConfig</code> in a library module</td>\n<td>The AGP KMP library plugin generates none</td>\n<td>Inject config from the app module</td>\n</tr>\n<tr>\n<td><code>debugImplementation(ui-tooling)</code> in a KMP module</td>\n<td>The plugin has no build types, so there is no debug configuration</td>\n<td><code>\"androidRuntimeClasspath\"(libs.compose.ui.tooling)</code></td>\n</tr>\n<tr>\n<td><code>consumer-rules.pro</code> present but never published</td>\n<td>The new plugin ships consumer keep rules only on request; the app's R8 strips reflected classes</td>\n<td><code>optimization { consumerKeepRules.apply { publish = true; file(...) } }</code></td>\n</tr>\n<tr>\n<td>Swift export and an Objective-C framework linked into one Xcode target</td>\n<td>Two Kotlin runtimes in one app</td>\n<td>One interop mode per Xcode target</td>\n</tr>\n<tr>\n<td>DI module never registered</td>\n<td>Runtime <code>NoDefinitionFoundException</code> on first screen open</td>\n<td>Add it to the app graph in step 5</td>\n</tr>\n</tbody>\n</table>\n<h2>Related skills</h2>\n<ul>\n<li><code>kmp-expect-actual</code> — platform code inside the new module.</li>\n<li><code>kmp-gradle-version-catalog</code> — catalog entries, convention plugins, composite builds.</li>\n<li><code>kmp-module-health</code> — audit the module once it exists.</li>\n<li><code>compose-multiplatform-navigation</code>, <code>kmp-swiftui-interop</code>, <code>kmp-xcframework-distribution</code> in this repo,\nfor navigation depth, the Swift side of the umbrella, and shipping it as an XCFramework.</li>\n<li><code>android-to-kmp-migration</code> — when the project is not KMP yet.</li>\n<li><a href=\"https://github.com/Kotlin/kotlin-agent-skills/tree/main/skills/kotlin-tooling-agp9-migration\"><code>kotlin-tooling-agp9-migration</code></a>\n(JetBrains) — move existing <code>androidTarget()</code> modules to the Android-KMP plugin; the same repo has\nKotlin/Native build-performance skills.</li>\n<li><a href=\"https://kotlinlang.org/docs/multiplatform/\">Kotlin Multiplatform docs</a>,\n<a href=\"https://developer.android.com/kotlin/multiplatform/plugin\">Android KMP library plugin</a> and\n<a href=\"https://kotlinlang.org/docs/native-swift-export.html\">Swift export</a>.</li>\n</ul>\n","files":[{"path":"references/gradle-templates.md","sizeBytes":17437,"isText":true},{"path":"references/ios-umbrella-framework.md","sizeBytes":8225,"isText":true},{"path":"SKILL.md","sizeBytes":22357,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-12-03T17:30:12.740302Z","sha256":"616D3AAE9ABF715A148169842EEA1CD1F04011307609DB71F0BCCE3A2F4EFBC2","sizeBytes":16851},"review":null,"source":{"repositoryUrl":"https://github.com/Kushpawan/kmp-mobile-skills","path":"skills/kmp-feature-module","license":"Apache-2.0","commit":"c04c11f696aa7a0f3c67761e5e48a7fd8201efa9","subtreeSha":"36E027C8994DA7508982CD4928A827626CA1EE9C819F7429D72753B1C881BC2A","lastSyncedAt":"2026-12-03T17:29:47.313948Z"},"reviewedAt":"2026-12-03T17:31:15.099919Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/Kushpawan/kmp-mobile-skills/tree/main/skills/kmp-feature-module"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install kushpawan-kmp-mobile-skills@llmmart"},{"target":"git","command":"git clone https://github.com/Kushpawan/kmp-mobile-skills.git"}]}