Overview
Last updated
Last updated
The provided diagram illustrates the code structure of a Cognito KMM project, which supports Android and iOS applications with shared code components and library. Below is a description of the structure as per the diagram:
androidApp
(Android App Project): This folder contains the Android-specific code for the Android application, including the AndroidManifest.xml
file and platform-specific configurations.
iosApp
(iOS Project): This folder contains the iOS-specific code for the iOS application, including the Podfile
and iOS platform configurations.
examples
: This folder contains example applications for both Android and iOS, showcasing how the shared modules can be used across different projects.
library
: This is the core platform where shared logic and functionality are implemented. The code here is reusable across different applications within this project and even across other projects. It provides common features like networking, data handling, and more.
shared
: This folder contains the code shared across the apps within this project. It consumes the library
module as a dependency, ensuring modularization and code reuse across platforms.
scripts
: This folder likely contains various build scripts or other utilities for automating tasks within the project.
exampleApp
and taskApp
: These folders represent the Android and iOS apps, with their respective source codes separated into Android and iOS-specific modules.
Code base for Android (androidMain
):
Contains platform-specific code for Android, such as configurations, Firebase services, and modules.
Modules like exampleModule
and taskModule
are part of the business logic for the respective apps.
Code base for iOS (iosMain
):
Contains platform-specific code for iOS, with configurations and modules like exampleModule
and taskModule
mirroring the Android structure.
Common Code (commonMain
):
Shared code for both Android and iOS is placed here. This can include common utilities, configuration, and modules used by both platforms to ensure consistency.
Modules:
exampleModule
: This module contains the specific logic and views required for the "example" application.
taskModule
: This module includes the logic and views for the "task" application.
These modules are part of both the androidMain
and iosMain
structures to facilitate sharing of business logic across platforms.
Common Resources (composeResources
):
A collection of resources and utilities, including Compose components and shared resources used across both Android and iOS apps.
build.gradle.kts
:
Build configuration files for both Android and iOS. This ensures that the dependencies, build scripts, and configuration are correctly applied for each platform.
Shared Code: The code under shared
is reusable across both Android and iOS applications, and it consumes the library
module for common functionality.
Modularization: Both Android and iOS apps have their own platform-specific code but share modules and configurations to ensure a consistent business logic implementation across both platforms.
Examples: The examples
folder provides reference applications to demonstrate how the shared codebase can be leveraged in different scenarios.
This structure enables scalable, maintainable, and reusable code across multiple platforms, ensuring that the business logic and UI components are shared whenever possible while still allowing platform-specific customizations.