The Kotlin Multiplatform Multi-module Template generator enables the development of cross-platform applications, supporting Android, iOS, Desktop, and Web. It allows for the sharing of business logic and UI components across these platforms while preserving native platform features and capabilities.
- buildLogic/: Contains shared Gradle build configurations and custom plugins
- core/: Contains the main business logic modules
analytics
: Analytics and logging utilitiescommon
: Shared code across all platformsmodel
: Data models and structuresdata
: Data layer implementationnetwork
: Network communication and API clientsdomain
: Business logic and use casesui
: Shared UI components using Compose Multiplatformdesignsystem
: App-wide design system componentsdatastore
: Local data storage implementation
- feature/: Contains feature-specific modules
home
: Home screen and related functionalityprofile
: User profile managementsettings
: Application settings
- mifospay-android/: Android application implementation
- mifospay-ios/: iOS application implementation
- mifospay-desktop/: Desktop application implementation
- mifospay-web/: Web application implementation
- mifospay-shared/: Shared Kotlin Multiplatform code
The project includes a bash script (customizer.sh
) that helps in customizing the project for different implementations. This script automates the process of renaming packages, updating configurations, and maintaining consistency across the project structure.
- Bash version 4 or higher
- Unix-like environment (macOS, Linux)
bash customizer.sh <package-name> <project-name> [application-name]
package-name
: New package name (e.g., com.example.myapp)project-name
: New project nameapplication-name
: (Optional) Custom application name (defaults to project-name)
bash customizer.sh com.example.myapp MyKMPApp
After running the customizer script to change package names and project structure, you'll need to update the license and copyright information across the project. This process involves:
- Locate License Files
- Navigate to the
spotless
directory - Find the license header templates
- Update the copyright year and organization information
- Navigate to the
- Apply Changes
- Run the Spotless plugin to update all files:
./gradlew spotlessApply
- This will automatically update the license headers in all source files
- Verify the changes in a few files to ensure correct application
- Run the Spotless plugin to update all files:
- Updates base package name across all modules
- Modifies Compose Resources configuration
- Updates Android Manifest package name
- Handles iOS bundle identifier updates
- Renames project-wide references
- Updates application class names
- Maintains consistency in capitalization and naming conventions
- Renames modules with new project prefix
- Updates module references in Gradle files
- Maintains correct module dependencies
- Updates import statements across the project
- Updates convention plugin IDs
- Modifies run configurations
- Updates build settings
- Handles iOS-specific configurations
- Renames files with project-specific prefixes
- Updates package declarations and imports
- Maintains typesafe accessors for Gradle
- Backup: The script creates backup files during execution (*.bak) and cleans them up after successful completion
- Error Handling: The script uses
set -e
to stop execution on any error - Platform Support: Handles configurations for all supported platforms (Android, iOS, Desktop, Web)
- Directory Structure: Maintains the KMP project structure while updating references
-
Before Running the Script
- Create a backup of your project
- Ensure you have the correct permissions
- Verify bash version compatibility
-
After Running the Script
- Verify the changes in your IDE
- Run a test build for each platform
- Check if all module references are correctly updated
-
Common Issues
- Package name formatting
- Module dependency resolution
- Platform-specific configuration updates
- Create a new feature module in the
feature/
directory - Follow the existing module structure
- Use shared components from
core/
modules - Implement platform-specific code in respective modules
- Use
expect/actual
declarations for platform-specific implementations - Leverage Compose Multiplatform for UI components
- Keep business logic in shared modules
- Use KMP-compatible dependencies
- Use appropriate run configurations for each platform
- Ensure all required SDKs are installed
- Follow platform-specific build instructions
graph TD
A[Project Root] --> B[buildLogic]
A --> C[core]
A --> D[feature]
A --> E[Platform Modules]
C --> C1[common]
C --> C2[model]
C --> C3[data]
C --> C4[network]
C --> C5[domain]
C --> C6[ui]
C --> C7[designsystem]
C --> C8[datastore]
D --> D1[home]
D --> D2[profile]
D --> D3[settings]
E --> E1[mifospay-android]
E --> E2[mifospay-ios]
E --> E3[mifospay-desktop]
E --> E4[mifospay-web]
E --> E5[mifospay-shared]
subgraph Core Modules
C1
C2
C3
C4
C5
C6
C7
C8
end
subgraph Feature Modules
D1
D2
D3
end
subgraph Platform Implementation
E1
E2
E3
E4
E5
end
- Follow the project's coding standards
- Write tests for new features
- Document changes and additions
- Submit pull requests with clear descriptions
- Check build logs for errors
- Verify module dependencies
- Ensure correct SDK versions
- Check platform-specific configurations