42 lines
2.3 KiB
Markdown
42 lines
2.3 KiB
Markdown
# Shared Module
|
|
|
|
KMP umbrella module that exports all core and feature modules as a single `Shared.framework` for iOS. On Android, this module is a dependency of `:app` but the framework export is iOS-only.
|
|
|
|
## Framework Export
|
|
|
|
`shared/build.gradle.kts` configures iOS targets (`iosArm64`, `iosSimulatorArm64`) and exports:
|
|
- `core:common`, `core:model`, `core:network`, `core:data` — exported via `api()` so iOS sees all public types
|
|
- `core:ui` + all `feature:*` modules — included via `implementation()` for Compose Multiplatform screen sharing
|
|
|
|
The framework is static (`isStatic = true`) and named `Shared`.
|
|
|
|
## iOS Platform Files (`src/iosMain/`)
|
|
|
|
| File | Purpose |
|
|
|------|---------|
|
|
| `IosKoinHelper.kt` | `startIosKoin()` — called from Swift `iOSApp.init()`. Sets up Kermit logging via NSLog, installs crash reporting, starts Koin with iOS modules. |
|
|
| `IosSharedModule.kt` | Koin module wiring Darwin Ktor engine, three HttpClient instances (main, streaming, refresh), all 16 API services, SSE client, and `LibreChatSDK`. |
|
|
| `IosKoinAccessor.kt` | Swift-accessible Koin resolver. `KoinHelper.swift` calls these to get SDK, repos, etc. |
|
|
| `IosCrashReporting.kt` | Unhandled exception hook — logs via Kermit + raises NSException for readable iOS crash logs. |
|
|
| `MainViewController.kt` | `MainViewController()` — the Compose Multiplatform entry point wrapped by `ComposeView.swift`. |
|
|
|
|
## Common Files (`src/commonMain/`)
|
|
|
|
- `LibreChatSDK.kt` — Facade class aggregating all API services, token manager, and SSE client
|
|
- `navigation/` — Nav 3 route definitions and entry providers shared across platforms
|
|
- `app/` — Shared app-level composables (root navigation host)
|
|
|
|
## SKIE
|
|
|
|
The SKIE Gradle plugin is applied here. All features are enabled by default:
|
|
- Sealed classes → Swift exhaustive enums (`onEnum(of:)`)
|
|
- `Flow<T>` → `AsyncSequence`
|
|
- `suspend fun` → `async throws`
|
|
|
|
No explicit SKIE configuration is needed unless disabling a specific feature.
|
|
|
|
## Adding Platform-Specific Code
|
|
|
|
- iOS implementations go in `src/iosMain/` with `actual` declarations matching `expect` in `commonMain`
|
|
- For feature-level platform code, prefer adding `iosMain` source sets in the feature module itself rather than here
|
|
- This module should only contain app-level iOS wiring (DI bootstrap, framework entry point)
|