Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiplatform #188

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -26,7 +26,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
50 changes: 50 additions & 0 deletions shared/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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"

compileSdk = libs.versions.compile.sdk.get().toInt()

defaultConfig {
minSdk = libs.versions.min.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()