Skip to content

Commit

Permalink
Multiplatform
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbel committed Feb 4, 2024
1 parent e5344e5 commit dcb972a
Show file tree
Hide file tree
Showing 27 changed files with 88 additions and 4 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ android {
targetCompatibility = JavaVersion.VERSION_17
}

targetProjectPath = ":app"
targetProjectPath = ":android-app"

experimentalProperties["android.experimental.self-instrumenting"] = true
}
Expand Down
2 changes: 1 addition & 1 deletion instant/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ android {
}

dependencies {
implementation(project(":app"))
implementation(project(":android-app"))
implementation(project(":core:common"))
implementation(project(":core:ui"))
implementation(libs.androidx.activity.compose)
Expand Down
5 changes: 3 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pluginManagement {
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
/*repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)*/
repositories {
mavenCentral()
google()
Expand All @@ -17,9 +17,10 @@ dependencyResolutionManagement {
rootProject.name = "movies"

include(
":app",
":android-app",
":instant",
":benchmark",
":shared",

":core:analytics",
":core:common",
Expand Down
49 changes: 49 additions & 0 deletions shared/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
plugins {
kotlin("multiplatform")
alias(libs.plugins.library)
}

@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class)
kotlin {
targetHierarchy.default()

androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "shared"
}
}

sourceSets {
val commonMain by getting {
dependencies {
//put your multiplatform dependencies here
}
}
val commonTest by getting {
dependencies {
//implementation(libs.kotlin.test)
}
}
}
}

android {
namespace = "org.michaelbel.movies.shared"

defaultConfig {
minSdk = libs.versions.min.sdk.get().toInt()
compileSdk = libs.versions.compile.sdk.get().toInt()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.michaelbel.movies.shared

import android.os.Build

class AndroidPlatform: Platform {
override val name: String = "Android ${Build.VERSION.SDK_INT}"
}

actual fun getPlatform(): Platform = AndroidPlatform()
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.michaelbel.movies.shared

class Greeting {
private val platform: Platform = getPlatform()

fun greet(): String {
return "Hello, ${platform.name}!"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.michaelbel.movies.shared

interface Platform {
val name: String
}

expect fun getPlatform(): Platform
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.michaelbel.movies.shared

import platform.UIKit.UIDevice

class IOSPlatform: Platform {
override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
}

actual fun getPlatform(): Platform = IOSPlatform()

0 comments on commit dcb972a

Please sign in to comment.