This project showcases a cross-platform mobile application (Android and iOS) built using Compose Multiplatform. It serves as a practical demonstration of developing a unified application across multiple platforms while seamlessly integrating platform-specific functionalities.
The project is thoughtfully organized to clearly separate shared logic from platform-specific implementations, ensuring maintainability and ease of navigation:
cmp-app-recipes/
├── androidApp/ # Android application source code and build configuration
├── iosApp/ # Xcode project and iOS application source code
├── shared/ # Core CMP module containing shared Kotlin code
│ ├── commonMain/ # Code shared between Android and iOS
│ ├── androidMain/ # Android-specific code
│ └── iosMain/ # iOS-specific code
├── build-logic/ # Custom Gradle plugins for build conventions
├── core/ # Shared modules across applications
│ ├── common/ # Generic classes and interfaces
│ ├── designsystem/ # UI design components
│ └── network/ # Network layer implementation
├── config/ # Configuration files
│ └── VERSION_NAME # Project version information
├── feature/ # Shared feature modules
│ └── login/ # Login feature implementation
└── .github/ # GitHub Actions workflows
%%{
init: {
'theme': 'neutral'
}
}%%
graph LR
subgraph :core
:core:common["common"]
:core:designsystem["designsystem"]
:core:network["network"]
:core:notification["notification"]
end
subgraph :feature
:feature:home["home"]
:feature:login["login"]
end
:feature:home --> :core:common
:feature:home --> :core:designsystem
:feature:home --> :core:network
:feature:login --> :core:common
:feature:login --> :core:designsystem
:feature:login --> :core:notification
:shared --> :core:designsystem
:shared --> :core:network
:shared --> :core:common
:shared --> :core:notification
:shared --> :feature:login
:shared --> :feature:home
:androidApp --> :shared
:core:notification --> :core:common
:core:notification --> :core:network
classDef kotlin-multiplatform fill:#C792EA,stroke:#fff,stroke-width:2px,color:#fff;
classDef android-application fill:#2C4162,stroke:#fff,stroke-width:2px,color:#fff;
class :feature:home kotlin-multiplatform
class :core:common kotlin-multiplatform
class :core:designsystem kotlin-multiplatform
class :core:network kotlin-multiplatform
class :feature:login kotlin-multiplatform
class :core:notification kotlin-multiplatform
class :shared kotlin-multiplatform
class :androidApp android-application
This project leverages the following powerful technologies:
- Compose Multiplatform (CMP): The foundation for building declarative UIs that can be shared across platforms.
- Kotlin: The expressive and concise programming language powering the application.
- Koin: A pragmatic lightweight dependency injection framework for Kotlin.
- Ktor: A powerful and flexible asynchronous HTTP client for Kotlin.
- Android Studio: The official IDE for Android development, used for the Android app and shared CMP module.
- Xcode: Apple's integrated development environment, essential for building the iOS application.
- GitHub Actions: For automating build, test, and deployment workflows.
Get started with the project by following these steps:
-
Prerequisites: Ensure the following tools are installed on your system:
- Java Development Kit (JDK): Version 21 or higher is required.
- Android Studio: Download and install from the official website.
- Xcode: Install from the Mac App Store.
- CocoaPods: If you intend to run the iOS application, install CocoaPods by running
sudo gem install cocoapodsin your terminal. - Kotlin Multiplatform Mobile Plugin: Within Android Studio, navigate to Preferences/Settings > Plugins, search for "Kotlin Multiplatform Mobile", and install it.
-
Clone the Repository:
git clone [email protected]:ricarlo-silva/cmp-app-recipes.git cd cmp-app-recipes
-
Open in Android Studio:
- Launch Android Studio.
- Select "Open an existing project."
- Browse to the
cmp-app-recipesdirectory and select it.
-
Sync Project with Gradle Files:
- Once the project is open, Android Studio will prompt you to synchronize with the Gradle files. Click "Sync Now" or the Gradle sync icon (elephant with a green arrow) in the toolbar.
-
Create
secrets.propertiesfile in the project root:- It should contain:
BASE_URL=your_base_api_url_hereAPI_KEY=your_api_key_here
- It should contain:
-
Run the Android App:
- Select the
androidAppconfiguration from the run configuration dropdown menu. - Create
google-services.jsonfile in theandroidAppdirectory. - Click the "Run" button (green play icon).
- Select the
-
Run the iOS App:
- Open the
iosApp/iosApp.xcodeprojfile in Xcode. - Create
GoogleService-Info.plistfile in theiosApp/iosAppdirectory. - Choose a simulator or connect a physical iOS device as the target.
- Click the "Run" button (play icon) in Xcode.
- Open the
- Android:
- Via Android Studio: Navigate to Build > Assemble Project.
- Via Gradle: Open a terminal in the project root and run
./gradlew androidApp:assembleDebug.
- iOS:
- Via Xcode: Go to Product > Build.
- Android:
- Unit Tests: Right-click on the
testdirectory withinandroidAppin Android Studio and select "Run 'All Tests'". Alternatively, use the terminal command:./gradlew androidApp:testDebugUnitTest. - Instrumentation Tests: Right-click on the
androidTestdirectory withinandroidAppand select "Run 'All Tests'".
- Unit Tests: Right-click on the
- Shared Code:
- Right-click on the
commonTestdirectory withinsharedand select "Run 'All Tests'". Alternatively, use the terminal command:./gradlew shared:test.
- Right-click on the
We highly appreciate contributions to this project! Please refer to the
CONTRIBUTING.md file for detailed guidelines on how you can contribute.
This project is licensed under the MIT license - see the LICENSE file for complete
license details.