aboutsummaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/build.gradle.kts62
-rw-r--r--shared/src/androidMain/AndroidManifest.xml2
-rw-r--r--shared/src/androidMain/kotlin/mx/trackermap/TrackerMap/Platform.kt5
-rw-r--r--shared/src/androidTest/kotlin/mx/trackermap/TrackerMap/androidTest.kt12
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/Greeting.kt7
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/Platform.kt5
-rw-r--r--shared/src/commonTest/kotlin/mx/trackermap/TrackerMap/commonTest.kt12
-rw-r--r--shared/src/iosMain/kotlin/mx/trackermap/TrackerMap/Platform.kt7
-rw-r--r--shared/src/iosTest/kotlin/mx/trackermap/TrackerMap/iosTest.kt12
9 files changed, 124 insertions, 0 deletions
diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts
new file mode 100644
index 0000000..72a5a1c
--- /dev/null
+++ b/shared/build.gradle.kts
@@ -0,0 +1,62 @@
+plugins {
+ kotlin("multiplatform")
+ id("com.android.library")
+}
+
+kotlin {
+ android()
+
+ listOf(
+ iosX64(),
+ iosArm64(),
+ //iosSimulatorArm64() sure all ios dependencies support this target
+ ).forEach {
+ it.binaries.framework {
+ baseName = "shared"
+ }
+ }
+
+ sourceSets {
+ val commonMain by getting
+ val commonTest by getting {
+ dependencies {
+ implementation(kotlin("test-common"))
+ implementation(kotlin("test-annotations-common"))
+ }
+ }
+ val androidMain by getting
+ val androidTest by getting {
+ dependencies {
+ implementation(kotlin("test-junit"))
+ implementation("junit:junit:4.13.2")
+ }
+ }
+ val iosX64Main by getting
+ val iosArm64Main by getting
+ //val iosSimulatorArm64Main by getting
+ val iosMain by creating {
+ dependsOn(commonMain)
+ iosX64Main.dependsOn(this)
+ iosArm64Main.dependsOn(this)
+ //iosSimulatorArm64Main.dependsOn(this)
+ }
+ val iosX64Test by getting
+ val iosArm64Test by getting
+ //val iosSimulatorArm64Test by getting
+ val iosTest by creating {
+ dependsOn(commonTest)
+ iosX64Test.dependsOn(this)
+ iosArm64Test.dependsOn(this)
+ //iosSimulatorArm64Test.dependsOn(this)
+ }
+ }
+}
+
+android {
+ compileSdk = 31
+ sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
+ defaultConfig {
+ minSdk = 21
+ targetSdk = 31
+ }
+} \ No newline at end of file
diff --git a/shared/src/androidMain/AndroidManifest.xml b/shared/src/androidMain/AndroidManifest.xml
new file mode 100644
index 0000000..f480b0f
--- /dev/null
+++ b/shared/src/androidMain/AndroidManifest.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest package="mx.trackermap.TrackerMap" /> \ No newline at end of file
diff --git a/shared/src/androidMain/kotlin/mx/trackermap/TrackerMap/Platform.kt b/shared/src/androidMain/kotlin/mx/trackermap/TrackerMap/Platform.kt
new file mode 100644
index 0000000..8a30a29
--- /dev/null
+++ b/shared/src/androidMain/kotlin/mx/trackermap/TrackerMap/Platform.kt
@@ -0,0 +1,5 @@
+package mx.trackermap.TrackerMap
+
+actual class Platform actual constructor() {
+ actual val platform: String = "Android ${android.os.Build.VERSION.SDK_INT}"
+} \ No newline at end of file
diff --git a/shared/src/androidTest/kotlin/mx/trackermap/TrackerMap/androidTest.kt b/shared/src/androidTest/kotlin/mx/trackermap/TrackerMap/androidTest.kt
new file mode 100644
index 0000000..9b2af46
--- /dev/null
+++ b/shared/src/androidTest/kotlin/mx/trackermap/TrackerMap/androidTest.kt
@@ -0,0 +1,12 @@
+package mx.trackermap.TrackerMap
+
+import org.junit.Assert.assertTrue
+import org.junit.Test
+
+class AndroidGreetingTest {
+
+ @Test
+ fun testExample() {
+ assertTrue("Check Android is mentioned", Greeting().greeting().contains("Android"))
+ }
+} \ No newline at end of file
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/Greeting.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/Greeting.kt
new file mode 100644
index 0000000..68b4100
--- /dev/null
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/Greeting.kt
@@ -0,0 +1,7 @@
+package mx.trackermap.TrackerMap
+
+class Greeting {
+ fun greeting(): String {
+ return "Hello, ${Platform().platform}!"
+ }
+} \ No newline at end of file
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/Platform.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/Platform.kt
new file mode 100644
index 0000000..9f39005
--- /dev/null
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/Platform.kt
@@ -0,0 +1,5 @@
+package mx.trackermap.TrackerMap
+
+expect class Platform() {
+ val platform: String
+} \ No newline at end of file
diff --git a/shared/src/commonTest/kotlin/mx/trackermap/TrackerMap/commonTest.kt b/shared/src/commonTest/kotlin/mx/trackermap/TrackerMap/commonTest.kt
new file mode 100644
index 0000000..87a789b
--- /dev/null
+++ b/shared/src/commonTest/kotlin/mx/trackermap/TrackerMap/commonTest.kt
@@ -0,0 +1,12 @@
+package mx.trackermap.TrackerMap
+
+import kotlin.test.Test
+import kotlin.test.assertTrue
+
+class CommonGreetingTest {
+
+ @Test
+ fun testExample() {
+ assertTrue(Greeting().greeting().contains("Hello"), "Check 'Hello' is mentioned")
+ }
+} \ No newline at end of file
diff --git a/shared/src/iosMain/kotlin/mx/trackermap/TrackerMap/Platform.kt b/shared/src/iosMain/kotlin/mx/trackermap/TrackerMap/Platform.kt
new file mode 100644
index 0000000..4c557dd
--- /dev/null
+++ b/shared/src/iosMain/kotlin/mx/trackermap/TrackerMap/Platform.kt
@@ -0,0 +1,7 @@
+package mx.trackermap.TrackerMap
+
+import platform.UIKit.UIDevice
+
+actual class Platform actual constructor() {
+ actual val platform: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
+} \ No newline at end of file
diff --git a/shared/src/iosTest/kotlin/mx/trackermap/TrackerMap/iosTest.kt b/shared/src/iosTest/kotlin/mx/trackermap/TrackerMap/iosTest.kt
new file mode 100644
index 0000000..5847b1c
--- /dev/null
+++ b/shared/src/iosTest/kotlin/mx/trackermap/TrackerMap/iosTest.kt
@@ -0,0 +1,12 @@
+package mx.trackermap.TrackerMap
+
+import kotlin.test.Test
+import kotlin.test.assertTrue
+
+class IosGreetingTest {
+
+ @Test
+ fun testExample() {
+ assertTrue(Greeting().greeting().contains("iOS"), "Check iOS is mentioned")
+ }
+} \ No newline at end of file