irsyad/kotlin-multiplatform-rules icon
public
Published on 3/30/2025
Kotlin Multiplatform Rules

Rules
kotlin-multiplatform-rules
## Build & Development Commands
- Use the Kotlin Multiplatform wizard to initialize new projects.
- Ensure all necessary dependencies and plugins (Kotlin Multiplatform, Compose Multiplatform, Ktor, SQLDelight, etc.) are correctly installed.
- Use Gradle for building the project:
  - `./gradlew build` to compile for all targets.
  - `./gradlew iosX64Binaries` for iOS.
  - `./gradlew androidDebug` for Android.
- Run the application:
  - `./gradlew installDebug` for Android.
  - Use Xcode to build and run for iOS.
- Keep dependencies updated and compatible with Kotlin Multiplatform.

## Testing Guidelines
- Write unit tests in the `commonTest` source set to ensure cross-platform compatibility.
- Implement platform-specific tests in `androidTest` and `iosTest` where necessary.
- Use `kotlin.test` framework for common tests and JUnit for Android tests.
- Automate tests with CI/CD pipelines (GitHub Actions, Bitrise, or GitLab CI/CD).
- Perform UI tests using Compose UI Test for Android and XCTest for iOS.
- Ensure snapshot testing for UI consistency across updates.

## Code Style & Guidelines
- Follow Kotlin official coding conventions (naming, indentation, imports, etc.).
- Organize source code properly:
  - Common business logic in `commonMain`.
  - Platform-specific implementations in `androidMain` and `iosMain`.
- Use Compose Multiplatform for shared UI components.
- Prefer dependency injection using Koin for shared logic.
- Ensure modularization for better maintainability and scalability.
- Avoid using platform-specific APIs unless necessary; abstract them via expect/actual mechanism.

## Documentation Guidelines
- Document all public APIs with KDoc.
- Maintain a README with clear project setup, dependencies, and architecture explanations.
- Include inline comments for complex logic and key decision points.
- Provide API documentation using Dokka for Kotlin libraries.
- Write platform-specific setup guides for Android and iOS developers.
- Maintain a CHANGELOG to track updates and improvements.