[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M74FTPQJ6R2M80XGJ77KW226":3,"skill-same:01M74FTPQJ6R2M80XGJ77KW226":49},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":20,"frontMatter":21,"refName":22,"commitSha":23,"skillDirectory":24,"forksCount":13,"repositoryHtmlUrl":25,"repositoryHomepageUrl":6,"ownerHtmlUrl":26,"ownerBlogUrl":6,"ownerDescription":27,"updatedAt":28,"install":29,"resources":42},"01M74FTPQJ6R2M80XGJ77KW226","kmp-ios-interop",null,"Astrumon\u002Fspovishun-skills","Astrumon","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F67917191?v=4","01M74FSGPFMM3XWY2PMSEN8Z2W","Danylo Bidnyk","01M74FSGQ12JX4QM4FEY6NEH6N",0,"MIT","https:\u002F\u002Fgithub.com\u002FAstrumon\u002Fspovishun-skills\u002Fblob\u002Fmain\u002Fskills\u002Fkmp-ios-interop\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"# KMP iOS Interop Skill\n\nThe Kotlin↔Swift boundary of a Kotlin Multiplatform module: how declarations are named in Swift, how\ntypes and nullability bridge, how `suspend` and `Flow` reach Swift concurrency through SKIE, how\nsealed classes become exhaustive `switch`es, and how to embed SwiftUI inside Compose.\n\n> **Unverified in this project.** No consumer project available here declares an iOS target, so\n> nothing below has been checked against a real build. It is adapted from\n> `rcosteira79\u002Fandroid-skills` → `kmp-boundaries\u002Freferences\u002Fios-interop.md`. Treat every claim as a\n> starting point to verify against the project's own SKIE and Kotlin versions, not as a settled fact.\n\n## Procedure\n\n1. **Check that an iOS target exists — before anything else.** Read `shared\u002Fbuild.gradle.kts` (or the\n   equivalent module) and look for `iosX64()`, `iosArm64()`, `iosSimulatorArm64()`, or an\n   `iosMain` source set.\n   **If none is declared, say so and stop.** This skill installs into every KMP project because there\n   is no `ios` stack flag; answering as though an iOS target exists would produce advice about a\n   framework the project never builds. Offer to hand adding the target to\n   **`kmp-multiplatform-specialist`**.\n2. **Read the framework configuration** — `binaries.framework { }`, whether SKIE is applied, and\n   which version. The SKIE-vs-manual answer depends entirely on this.\n3. **Answer or change against those facts**, keeping the boundary surface as small as it already is.\n4. **Verify.** Build the framework (`.\u002Fgradlew :shared:linkDebugFrameworkIosSimulatorArm64`) and\n   report the real output. On a non-macOS machine, say plainly that the build could not be run here.\n\n## Scope\n\n**In scope**\n- Kotlin→Swift naming, nullability and type-width bridging.\n- `suspend` → Swift `async`, `Flow` → `AsyncSequence`, with and without SKIE.\n- Sealed-class exhaustiveness in Swift.\n- Keeping the ObjC header surface small (`internal`, `@HiddenFromObjC`).\n- Embedding SwiftUI or UIKit views inside Compose Multiplatform.\n\n**Out of scope — hand off, do not answer here**\n- Adding or configuring the iOS target itself → **`kmp-multiplatform-specialist`**\n- Which layer a boundary type belongs to → `.claude\u002Frules\u002Fkmp\u002Farchitecture.md`\n- Koin startup from Swift → **`koin-kmp`**\n- The Compose side of an embedded view's layout → **`compose-multiplatform`**\n- Swift application code beyond the call site — that is outside this plugin entirely\n\n## Naming\n\n| Kotlin | Swift |\n|---|---|\n| top-level `fun foo()` in `Bar.kt` | `BarKt.foo()` — file name + `Kt` |\n| `object AppInit` | `AppInit.shared` |\n| `companion object` member | directly on the class, no `Companion` namespace |\n| `suspend fun load()` | `async func load()` with SKIE |\n| generic types | erased or boxed unpredictably — use concrete types at the boundary |\n\nSwift reserves `init`, so a Kotlin `initKoin()` called from `iOSApp.init()` is normally renamed\n(`doInitKoin`) rather than fought with.\n\n## Type bridging\n\n| Kotlin | Swift | Watch for |\n|---|---|---|\n| `String` \u002F `String?` | `String` \u002F `String?` | bridges cleanly |\n| `Int` \u002F `Long` | `Int32` \u002F `Int64` | **not** Swift `Int`, which is platform-sized. Cross-boundary arithmetic needs explicit casts |\n| `Unit` | `KotlinUnit` | the caller must discard it explicitly — avoid in public API |\n| `List\u003CT>` \u002F `Map\u003CK, V>` | `[T]` \u002F `[K: V]`, read-only **copies** | structural sharing is lost; batch, never iterate across the boundary in a hot path |\n\nThe `Int` width mismatch is the most common defect here, and it is silent until a value exceeds 32\nbits or a Swift API refuses the type.\n\n## Coroutines and Flow\n\nSKIE is the default for a new project: it converts `suspend` to Swift `async` and `Flow` to\n`AsyncSequence` with no annotations on the Kotlin side, at the cost of a build plugin.\nKMP-NativeCoroutines (`@NativeCoroutines`) is the annotation-driven alternative — keep it if the\nproject already uses it, do not introduce it alongside SKIE.\n\n```kotlin\n\u002F\u002F commonMain — nothing iOS-specific\nsuspend fun loadItems(): List\u003CItem> = repository.getAll()\n```\n\n```swift\nlet items = try await viewModel.loadItems()\n\n\u002F\u002F StateFlow\u003CUiState> — the MVI bridge\nfor await state in viewModel.state {\n    self.uiState = state\n}\n```\n\nWithout SKIE, expose a callback-based observer from `iosMain` that returns a cancel closure, and call\nit from Swift `deinit`:\n\n```kotlin\n\u002F\u002F iosMain\nclass IosStateCollector\u003CT>(private val flow: StateFlow\u003CT>, private val scope: CoroutineScope) {\n    private var job: Job? = null\n\n    fun observe(onChange: (T) -> Unit): () -> Unit {\n        job = scope.launch(Dispatchers.Main) { flow.collect { onChange(it) } }\n        return { job?.cancel() }\n    }\n}\n```\n\nA collector whose cancel closure Swift never calls is a leak that no Kotlin test will find.\n\n## Sealed classes\n\nWithout SKIE, Swift sees a class hierarchy and `as?` casts — **no exhaustiveness check**, so adding a\nsealed subclass silently breaks the iOS UI while everything still compiles. With SKIE:\n\n```swift\nswitch onEnum(of: state) {\ncase .loading: showSpinner()\ncase .success(let s): render(items: s.items)\ncase .error(let e): showError(e.message)\n}   \u002F\u002F now a compiler error when a new subclass appears\n```\n\nEdge cases: SKIE cannot convert **generic** sealed classes — use a concrete `ItemListState`, not\n`ListState\u003CItem>`. Nested hierarchies flatten (`UiState.Error.Network` → `.errorNetwork`).\n`@SealedInterop.Disabled` opts a single class out.\n\n## Keeping the surface small\n\n- `internal` plus `@HiddenFromObjC` keeps Kotlin internals out of the generated ObjC header.\n- No generics in iOS-facing public API.\n- Data classes over deep hierarchies at the boundary.\n- `isStatic = true` in the framework config — smaller binary, faster startup.\n\n## Embedding SwiftUI in Compose\n\nSwiftUI views cannot be passed to Compose directly; wrap them in a `UIHostingController` on the Swift\nside and hand the controller to a Kotlin factory:\n\n```kotlin\n\u002F\u002F iosMain\n@OptIn(ExperimentalForeignApi::class)\nfun ComposeWithSwiftUI(createViewController: () -> UIViewController): UIViewController =\n    ComposeUIViewController {\n        Column(Modifier.fillMaxSize()) {\n            Text(\"Compose content above\")\n            UIKitViewController(factory = createViewController, modifier = Modifier.size(300.dp))\n        }\n    }\n```\n\n```swift\nMainViewControllerKt.ComposeWithSwiftUI {\n    UIHostingController(rootView: MySwiftUIMapView())\n}\n```\n\nPlain UIKit views (`MKMapView`, `WKWebView`, `AVCaptureSession`) need no Swift bridge — use\n`UIKitView(factory = { … })` from Kotlin.\n\n## Testing on iOS\n\nThe source-set table in `.claude\u002Frules\u002Fkmp\u002Ftesting.md` covers the targets every KMP project shares;\nthe iOS row lives here so projects without an iOS target never load it.\n\n| Source set | Framework | What goes here |\n|---|---|---|\n| `iosTest` | `kotlin.test` + `kotlinx-coroutines-test` | iOS `actual`s and Swift-facing behaviour of the boundary |\n\n- `commonTest` already runs on the iOS simulator target, so a behaviour that is not iOS-specific stays\n  there. `iosTest` is for the `actual`s and the exported surface.\n- Kotlin\u002FNative has no MockK and no reflection-based mocking: fakes only, which `commonTest` already\n  requires.\n- Swift-side behaviour (SKIE `async` bridging, `AsyncSequence` cancellation) is covered from XCTest in\n  the iOS app, not from Kotlin — state that when it was not run.\n\n## Do NOT\n\n- Do NOT answer any of this for a project with no iOS target — check first, then stop.\n- Do NOT expose generics across the boundary.\n- Do NOT return `Unit` from a `suspend` function that Swift calls.\n- Do NOT assume Kotlin `Int` and Swift `Int` are the same width.\n- Do NOT pass large collections across the boundary repeatedly — batch.\n- Do NOT rely on `as?` chains for sealed state; they are silently non-exhaustive.\n- Do NOT add both SKIE and KMP-NativeCoroutines.\n- Do NOT claim a framework build passed if it was not run.\n\n## Error handling\n\n- **No iOS target declared** → say so, name what you looked at, and stop.\n- **SKIE not applied but `async`\u002F`AsyncSequence` is expected** → report the missing plugin and the\n  manual-collector alternative; do not silently write SKIE-only Swift.\n- **A generic sealed class must cross the boundary** → propose the concrete replacement type rather\n  than disabling exhaustiveness.\n- **The framework build cannot run here (non-macOS host)** → state that plainly and mark the change\n  unverified. Never report a green iOS build you did not execute.\n- **The question is about the Compose side of an embedded view** → hand it to\n  **`compose-multiplatform`**.\n\n## Example\n\n> \"Expose the dashboard state to SwiftUI.\"\n\n1. Read the module's build file; report the declared targets. **If there is no iOS target, stop here\n   and say so.**\n2. Report whether SKIE is applied and at which version.\n3. Check the state type: if it is `UiState\u003CT>`, propose a concrete `DashboardUiState` — SKIE cannot\n   make a generic sealed class exhaustive in Swift.\n4. Confirm `StateFlow` exposure (not `MutableStateFlow`) and that `Int` fields crossing the boundary\n   are handled.\n5. Build the framework and report the real output, or state that the host cannot build it.\n\nExpected outcome: a concrete, non-generic state type at the boundary and an explicit statement of\nwhat was and was not verified.\n\n## Related Skills\n\n- `kmp-multiplatform-specialist` — adding the iOS target, `expect`\u002F`actual`, source sets\n- `compose-multiplatform` — the Compose side of embedded views\n- `koin-kmp` — DI startup from Swift\n- `kotlin-specialist` — `StateFlow`, scope ownership, cancellation\n- `kmp-testing` — what can and cannot be covered by tests here\n",{},"main","4ad702b3d4f403306c1a016277020693dd669f55","skills\u002Fkmp-ios-interop","https:\u002F\u002Fgithub.com\u002FAstrumon\u002Fspovishun-skills","https:\u002F\u002Fgithub.com\u002FAstrumon","Software Engineer","2026-10-14 01:01:46",{"source":7,"skillName":5,"commands":30,"prompt":40,"zipAvailable":41},[31,34,37],{"tool":32,"command":33},"npx","npx skills add Astrumon\u002Fspovishun-skills --skill kmp-ios-interop",{"tool":35,"command":36},"bunx","bunx skills add Astrumon\u002Fspovishun-skills --skill kmp-ios-interop",{"tool":38,"command":39},"pnpm","pnpm dlx skills add Astrumon\u002Fspovishun-skills --skill kmp-ios-interop","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FAstrumon\u002Fspovishun-skills\u002Fblob\u002Fmain\u002Fskills\u002Fkmp-ios-interop\u002FSKILL.md",true,[43],{"path":44,"resourceType":45,"resourceTypeDesc":46,"sizeBytes":47,"sourceHtmlUrl":48},"manifest.yaml","REFERENCE","参考文档",1050,"https:\u002F\u002Fgithub.com\u002FAstrumon\u002Fspovishun-skills\u002Fblob\u002Fmain\u002Fskills\u002Fkmp-ios-interop\u002Fmanifest.yaml",[50,56,62,69,74,79],{"skillNo":51,"name":52,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":18},"01M74FX71JH2KNG5KX7TZHSKCB","universal-skill","https:\u002F\u002Fgithub.com\u002FAstrumon\u002Fspovishun-skills\u002Fblob\u002Fmain\u002Ftest\u002Ffixtures\u002Fsource\u002Fskills\u002Funiversal-skill\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":18},"01M74FX57GTEFPJVCPWPSP6CCW","notion-skill","https:\u002F\u002Fgithub.com\u002FAstrumon\u002Fspovishun-skills\u002Fblob\u002Fmain\u002Ftest\u002Ffixtures\u002Fsource\u002Fskills\u002Fnotion-skill\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":18},"01M74FX30F3K8906P5ASQ3DNXR","inline-frontmatter-skill","Hand-authored description that already lives in the body and must not be double-wrapped.","https:\u002F\u002Fgithub.com\u002FAstrumon\u002Fspovishun-skills\u002Fblob\u002Fmain\u002Ftest\u002Ffixtures\u002Fsource\u002Fskills\u002Finline-frontmatter-skill\u002FSKILL.md",[],[],{"skillNo":70,"name":52,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":18},"01M74FX18AGHM2KHQ502PMJZRJ","https:\u002F\u002Fgithub.com\u002FAstrumon\u002Fspovishun-skills\u002Fblob\u002Fmain\u002Ftest\u002Ffixtures\u002Fsource-v2\u002Fskills\u002Funiversal-skill\u002FSKILL.md",[],[],{"skillNo":75,"name":58,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":18},"01M74FWZJ193G810P0ZJ1PKEZ9","https:\u002F\u002Fgithub.com\u002FAstrumon\u002Fspovishun-skills\u002Fblob\u002Fmain\u002Ftest\u002Ffixtures\u002Fsource-v2\u002Fskills\u002Fnotion-skill\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":18},"01M74FWPNEZWWGQ2Q37N6MMWP1","write-a-skill","https:\u002F\u002Fgithub.com\u002FAstrumon\u002Fspovishun-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwrite-a-skill\u002FSKILL.md",[],[]]