Skip to content

Ankitchhipa/KMM

Repository files navigation

KMM Login Demo

This is a Kotlin Multiplatform login/logout demo for Android and iOS. The session state and Compose UI live in the shared KMP module, while Android and iOS only host that shared UI.

Project structure

  • androidApp: Android application entry point.
  • iosApp: iOS SwiftUI application entry point.
  • shared: Shared Kotlin and Compose Multiplatform code.
  • shared/src/commonMain/kotlin/com/io/kmm/SessionManager.kt: Shared session logic with login() and logout().
  • shared/src/commonMain/kotlin/com/io/kmm/App.kt: Shared Compose UI used by Android and iOS.
  • shared/src/iosMain/kotlin/com/io/kmm/MainViewController.kt: Exposes the shared Compose UI as an iOS UIViewController.
  • iosApp/iosApp/ContentView.swift: Hosts the shared MainViewController() inside SwiftUI.

Requirements

  • Android Studio with Kotlin Multiplatform support.
  • JDK 11 or newer.
  • Android SDK installed with the compile SDK configured by the project.
  • For iOS: macOS with Xcode installed. iOS apps cannot be run from Windows.

Run the Android app

  1. Open this project in Android Studio.
  2. Let Gradle sync finish.
  3. Select the androidApp run configuration.
  4. Choose an Android emulator or connected device.
  5. Click Run.

Build the debug APK from a terminal:

./gradlew :androidApp:assembleDebug

On Windows PowerShell:

.\gradlew.bat :androidApp:assembleDebug

The APK is generated at:

androidApp/build/outputs/apk/debug/androidApp-debug.apk

Run the iOS app

  1. Open iosApp/iosApp.xcodeproj in Xcode on macOS.
  2. Select the iosApp scheme.
  3. Choose an iPhone simulator or a connected iPhone.
  4. Click Run.

The Xcode project already includes a build phase that runs:

./gradlew :shared:embedAndSignAppleFrameworkForXcode

That task builds and embeds the Shared KMP framework used by the SwiftUI app. The iOS screen calls MainViewControllerKt.MainViewController(), which renders the same shared login/logout UI used by Android.

Verify shared code

Run the shared module tests:

./gradlew :shared:allTests

On Windows PowerShell:

.\gradlew.bat :shared:allTests

About

This is a Kotlin Multiplatform login/logout demo for Android and iOS. The session state and Compose UI live in the shared KMP module, while Android and iOS only host that shared UI.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors