Skip to content

Commit a2d479e

Browse files
authored
Merge pull request #30 from joreilly/kotlin_1_8
Kotlin 1.8 changes
2 parents 076af65 + 5d538c5 commit a2d479e

File tree

32 files changed

+667
-279
lines changed

32 files changed

+667
-279
lines changed

SharedCode/build.gradle.kts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ plugins {
55
id("com.android.library")
66
id("org.jetbrains.kotlin.native.cocoapods")
77
id("com.squareup.sqldelight")
8+
id("com.google.devtools.ksp")
89
id("com.rickclephas.kmp.nativecoroutines")
910
}
1011

@@ -21,11 +22,11 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
2122

2223

2324
android {
24-
compileSdk = Versions.androidCompileSdk
25+
compileSdk = AndroidSdk.compile
2526
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
2627
defaultConfig {
27-
minSdk = Versions.androidMinSdk
28-
targetSdk = Versions.androidTargetSdk
28+
minSdk = AndroidSdk.min
29+
targetSdk = AndroidSdk.target
2930

3031
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
3132
}
@@ -138,3 +139,7 @@ sqldelight {
138139
}
139140
}
140141

142+
kotlin.sourceSets.all {
143+
languageSettings.optIn("kotlin.experimental.ExperimentalObjCName")
144+
}
145+

SharedCode/src/androidMain/kotlin/com/surrus/galwaybus/common/di/KoinAndroid.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
package com.surrus.galwaybus.common.di
22

33
import android.content.Context
4-
import com.russhwolf.settings.AndroidSettings
5-
import com.russhwolf.settings.ExperimentalSettingsApi
64
import com.russhwolf.settings.ObservableSettings
5+
import com.russhwolf.settings.SharedPreferencesSettings
76
import com.squareup.sqldelight.android.AndroidSqliteDriver
87
import com.surrus.galwaybus.db.MyDatabase
98
import org.koin.dsl.module
109

11-
@OptIn(ExperimentalSettingsApi::class)
1210
actual fun platformModule() = module {
1311
single { createObservableSettings(get()) }
1412
single { createDb(get()) }
1513
}
1614

1715

18-
@OptIn(ExperimentalSettingsApi::class)
1916
private fun createObservableSettings(context: Context): ObservableSettings {
20-
return AndroidSettings(context.getSharedPreferences("AppSettings", Context.MODE_PRIVATE))
17+
return SharedPreferencesSettings(context.getSharedPreferences("AppSettings", Context.MODE_PRIVATE))
2118
}
2219

2320
fun createDb(context: Context): MyDatabase {

SharedCode/src/commonMain/kotlin/com/surrus/galwaybus/common/GalwayBusRepository.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
package com.surrus.galwaybus.common
22

33
import co.touchlab.kermit.Logger
4+
import com.rickclephas.kmp.nativecoroutines.NativeCoroutineScope
5+
import com.rickclephas.kmp.nativecoroutines.NativeCoroutines
46
import com.squareup.sqldelight.runtime.coroutines.asFlow
57
import com.squareup.sqldelight.runtime.coroutines.mapToList
68
import com.surrus.galwaybus.common.model.*
79
import com.surrus.galwaybus.common.remote.CityBikesApi
810
import com.surrus.galwaybus.common.remote.GalwayBusApi
911
import com.surrus.galwaybus.common.remote.Station
1012
import com.surrus.galwaybus.db.MyDatabase
13+
import kotlinx.coroutines.CoroutineScope
14+
import kotlinx.coroutines.MainScope
1115
import kotlinx.coroutines.flow.combine
1216
import kotlinx.datetime.Clock
1317
import kotlinx.datetime.Instant
@@ -18,6 +22,9 @@ import kotlin.time.Duration
1822

1923

2024
open class GalwayBusRepository : KoinComponent {
25+
@NativeCoroutineScope
26+
val coroutineScope: CoroutineScope = MainScope()
27+
2128
private val galwayBusApi: GalwayBusApi = get()
2229
private val cityBikesApi: CityBikesApi by inject()
2330

@@ -29,7 +36,9 @@ open class GalwayBusRepository : KoinComponent {
2936
BusStop(stop_id, short_name, long_name, stop_ref, latitude = latitude, longitude = longitude)
3037
}).asFlow().mapToList()
3138

39+
@NativeCoroutines
3240
val favorites = appSettings.favorites
41+
3342
val favoriteBusStopList = busStops.combine(favorites) { busStops, favorites ->
3443
Logger.i { "getBusStopsFlow().combine, favorites = $favorites, busStops size = ${busStops.size}" }
3544
favorites.map { favorite -> busStops.firstOrNull { it.stop_id == favorite } }.filterNotNull()
@@ -55,6 +64,7 @@ open class GalwayBusRepository : KoinComponent {
5564
}
5665
}
5766

67+
@NativeCoroutines
5868
suspend fun fetchRouteStops(routeId: String): Result<List<List<BusStop>>> {
5969
try {
6070
val busStopLists = galwayBusApi.fetchRouteStops(routeId)
@@ -73,6 +83,7 @@ open class GalwayBusRepository : KoinComponent {
7383
}
7484
}
7585

86+
@NativeCoroutines
7687
suspend fun fetchBusStopDepartures(stopRef: String): Result<List<GalwayBusDeparture>> {
7788
try {
7889
val busStopResponse = galwayBusApi.fetchBusStop(stopRef)
@@ -97,11 +108,13 @@ open class GalwayBusRepository : KoinComponent {
97108
}
98109
}
99110

111+
@NativeCoroutines
100112
suspend fun fetchBusRoutes(): List<BusRoute> {
101113
val busRoutes = galwayBusApi.fetchBusRoutes()
102114
return transformBusRouteMapToList(busRoutes)
103115
}
104116

117+
@NativeCoroutines
105118
suspend fun fetchNearestStops(latitude: Double, longitude: Double): Result<List<BusStop>> {
106119
try {
107120
val busStops = galwayBusApi.fetchNearestStops(latitude, longitude)

SharedCode/src/iosMain/kotlin/com/surrus/galwaybus/common/di/KoiniOS.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
package com.surrus.galwaybus.common.di
22

3-
import com.russhwolf.settings.AppleSettings
4-
import com.russhwolf.settings.ExperimentalSettingsApi
3+
import com.russhwolf.settings.NSUserDefaultsSettings
54
import com.russhwolf.settings.ObservableSettings
65
import com.squareup.sqldelight.drivers.native.NativeSqliteDriver
76
import com.surrus.galwaybus.db.MyDatabase
87
import org.koin.dsl.module
98
import platform.Foundation.NSUserDefaults
109

11-
@OptIn(ExperimentalSettingsApi::class)
1210
actual fun platformModule() = module {
13-
single<ObservableSettings> { AppleSettings(NSUserDefaults.standardUserDefaults) }
11+
single<ObservableSettings> { NSUserDefaultsSettings(NSUserDefaults.standardUserDefaults) }
1412
single { createDb() }
1513
}
1614

android-app/build.gradle.kts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fun versionName(): String {
4040

4141

4242
android {
43-
compileSdk = Versions.androidCompileSdk
43+
compileSdk = AndroidSdk.compile
4444

4545
signingConfigs {
4646

@@ -62,8 +62,8 @@ android {
6262

6363
defaultConfig {
6464
applicationId = "dev.johnoreilly.galwaybus"
65-
minSdk = Versions.androidMinSdk
66-
targetSdk = Versions.androidTargetSdk
65+
minSdk = AndroidSdk.min
66+
targetSdk = AndroidSdk.target
6767

6868
this.versionCode = versionCode()
6969
this.versionName = versionName()
@@ -101,7 +101,12 @@ android {
101101

102102
kotlinOptions {
103103
jvmTarget = "1.8"
104+
freeCompilerArgs += listOf(
105+
"-P",
106+
"plugin:androidx.compose.compiler.plugins.kotlin:suppressKotlinVersionCompatibilityCheck=true"
107+
)
104108
}
109+
105110
packagingOptions {
106111
resources {
107112
excludes += setOf("META-INF/*.kotlin_module")

build.gradle.kts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ buildscript {
77
}
88

99
dependencies {
10-
classpath("com.android.tools.build:gradle:7.2.1")
10+
classpath("com.android.tools.build:gradle:7.4.0")
1111
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}")
1212
classpath("org.jetbrains.kotlin:kotlin-serialization:${Versions.kotlin}")
1313
classpath("com.squareup.sqldelight:gradle-plugin:${Versions.sqlDelight}")
14-
classpath("com.google.gms:google-services:4.3.13")
14+
classpath("com.google.gms:google-services:4.3.15")
15+
classpath("com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:1.8.0-1.0.8")
1516
classpath("com.rickclephas.kmp:kmp-nativecoroutines-gradle-plugin:${Versions.kmpNativeCoroutines}")
1617
}
1718
}
@@ -20,6 +21,7 @@ allprojects {
2021
repositories {
2122
google()
2223
mavenCentral()
24+
maven("https://androidx.dev/storage/compose-compiler/repository")
2325
}
2426
}
2527

buildSrc/src/main/java/Dependencies.kt

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11

22
object Versions {
3-
const val androidMinSdk = 21
4-
const val androidCompileSdk = 33
5-
const val androidTargetSdk = androidCompileSdk
6-
7-
const val kotlin = "1.7.20"
3+
const val kotlin = "1.8.0"
84
const val kotlinCoroutines = "1.6.4"
9-
const val kotlinxSerialization = "1.3.3"
5+
const val kotlinxSerialization = "1.4.1"
6+
const val ktor = "2.2.2"
107
const val kotlinxDateTime = "0.4.0"
11-
const val koinCore = "3.3.0"
12-
const val koinAndroid = "3.3.1"
13-
const val koinAndroidCompose = "3.4.0"
14-
const val sqlDelight = "1.5.4"
15-
const val multiplatformSettings = "1.0.0-alpha01"
16-
const val kmpNativeCoroutines = "0.13.1"
8+
const val koinCore = "3.3.2"
9+
const val koinAndroid = "3.3.2"
10+
const val koinAndroidCompose = "3.4.1"
11+
const val sqlDelight = "1.5.5"
12+
const val multiplatformSettings = "1.0.0"
13+
14+
const val kmpNativeCoroutines = "1.0.0-ALPHA-4"
1715

1816
const val compose = "1.4.0-alpha03"
19-
const val composeCompiler = "1.3.2"
17+
const val composeCompiler = "1.4.0"
2018
const val navCompose = "2.5.2"
21-
const val accompanist = "0.26.5-rc"
22-
const val mapsCompose = "2.5.3"
19+
const val accompanist = "0.29.0-alpha"
20+
const val mapsCompose = "2.8.1"
2321
const val composeMaterial3 = "1.0.0"
2422

2523
const val kermit = "1.0.0"
26-
const val ktor = "2.0.0"
2724
const val slf4j = "1.7.30"
2825

2926
const val junit = "4.12"
@@ -32,13 +29,18 @@ object Versions {
3229
}
3330

3431

32+
object AndroidSdk {
33+
const val min = 21
34+
const val compile = 33
35+
const val target = compile
36+
}
37+
3538
object Firebase {
3639
val core = "com.google.firebase:firebase-core:16.0.9"
3740
val performance = "com.google.firebase:firebase-perf:16.2.3"
3841
}
3942

4043

41-
4244
object Deps {
4345

4446
object Kotlinx {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Sat May 21 11:44:03 IST 2022
22
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
43
distributionPath=wrapper/dists
54
zipStorePath=wrapper/dists
65
zipStoreBase=GRADLE_USER_HOME
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip

ios/GalwayBusAppSwiftUI/GalwayBusAppSwiftUI.xcodeproj/project.pbxproj

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
1A1D520028393F0600F2BB1A /* KMPNativeCoroutinesAsync in Frameworks */ = {isa = PBXBuildFile; productRef = 1A1D51FF28393F0600F2BB1A /* KMPNativeCoroutinesAsync */; };
11-
1A1D520228393F0600F2BB1A /* KMPNativeCoroutinesCore in Frameworks */ = {isa = PBXBuildFile; productRef = 1A1D520128393F0600F2BB1A /* KMPNativeCoroutinesCore */; };
1210
1A9038C62337992F00E57AC4 /* MapView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A9038C52337992F00E57AC4 /* MapView.swift */; };
11+
1AD11A39297BF584001540C5 /* KMPNativeCoroutinesAsync in Frameworks */ = {isa = PBXBuildFile; productRef = 1AD11A38297BF584001540C5 /* KMPNativeCoroutinesAsync */; };
12+
1AD11A3B297BF584001540C5 /* KMPNativeCoroutinesCore in Frameworks */ = {isa = PBXBuildFile; productRef = 1AD11A3A297BF584001540C5 /* KMPNativeCoroutinesCore */; };
1313
B214E8E922BAD6DD0041C7C8 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = B214E8E822BAD6DD0041C7C8 /* libsqlite3.tbd */; };
1414
B22B4EC422A5BF1D0026DB68 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B22B4EC322A5BF1D0026DB68 /* AppDelegate.swift */; };
1515
B22B4EC622A5BF1D0026DB68 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B22B4EC522A5BF1D0026DB68 /* SceneDelegate.swift */; };
@@ -45,8 +45,8 @@
4545
files = (
4646
B214E8E922BAD6DD0041C7C8 /* libsqlite3.tbd in Frameworks */,
4747
E4D277E57E09FA972A967A9D /* Pods_GalwayBusAppSwiftUI.framework in Frameworks */,
48-
1A1D520228393F0600F2BB1A /* KMPNativeCoroutinesCore in Frameworks */,
49-
1A1D520028393F0600F2BB1A /* KMPNativeCoroutinesAsync in Frameworks */,
48+
1AD11A3B297BF584001540C5 /* KMPNativeCoroutinesCore in Frameworks */,
49+
1AD11A39297BF584001540C5 /* KMPNativeCoroutinesAsync in Frameworks */,
5050
);
5151
runOnlyForDeploymentPostprocessing = 0;
5252
};
@@ -124,15 +124,16 @@
124124
B22B4EBC22A5BF1D0026DB68 /* Sources */,
125125
B22B4EBD22A5BF1D0026DB68 /* Frameworks */,
126126
B22B4EBE22A5BF1D0026DB68 /* Resources */,
127+
A289C8BAA3E3183943457E5B /* [CP] Embed Pods Frameworks */,
127128
);
128129
buildRules = (
129130
);
130131
dependencies = (
131132
);
132133
name = GalwayBusAppSwiftUI;
133134
packageProductDependencies = (
134-
1A1D51FF28393F0600F2BB1A /* KMPNativeCoroutinesAsync */,
135-
1A1D520128393F0600F2BB1A /* KMPNativeCoroutinesCore */,
135+
1AD11A38297BF584001540C5 /* KMPNativeCoroutinesAsync */,
136+
1AD11A3A297BF584001540C5 /* KMPNativeCoroutinesCore */,
136137
);
137138
productName = GalwayBusAppSwiftUI;
138139
productReference = B22B4EC022A5BF1D0026DB68 /* GalwayBusAppSwiftUI.app */;
@@ -163,7 +164,7 @@
163164
);
164165
mainGroup = B22B4EB722A5BF1D0026DB68;
165166
packageReferences = (
166-
1A1D51FE28393F0600F2BB1A /* XCRemoteSwiftPackageReference "KMP-NativeCoroutines" */,
167+
1AD11A37297BF584001540C5 /* XCRemoteSwiftPackageReference "KMP-NativeCoroutines.git" */,
167168
);
168169
productRefGroup = B22B4EC122A5BF1D0026DB68 /* Products */;
169170
projectDirPath = "";
@@ -210,6 +211,23 @@
210211
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
211212
showEnvVarsInLog = 0;
212213
};
214+
A289C8BAA3E3183943457E5B /* [CP] Embed Pods Frameworks */ = {
215+
isa = PBXShellScriptBuildPhase;
216+
buildActionMask = 2147483647;
217+
files = (
218+
);
219+
inputFileListPaths = (
220+
"${PODS_ROOT}/Target Support Files/Pods-GalwayBusAppSwiftUI/Pods-GalwayBusAppSwiftUI-frameworks-${CONFIGURATION}-input-files.xcfilelist",
221+
);
222+
name = "[CP] Embed Pods Frameworks";
223+
outputFileListPaths = (
224+
"${PODS_ROOT}/Target Support Files/Pods-GalwayBusAppSwiftUI/Pods-GalwayBusAppSwiftUI-frameworks-${CONFIGURATION}-output-files.xcfilelist",
225+
);
226+
runOnlyForDeploymentPostprocessing = 0;
227+
shellPath = /bin/sh;
228+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-GalwayBusAppSwiftUI/Pods-GalwayBusAppSwiftUI-frameworks.sh\"\n";
229+
showEnvVarsInLog = 0;
230+
};
213231
/* End PBXShellScriptBuildPhase section */
214232

215233
/* Begin PBXSourcesBuildPhase section */
@@ -421,25 +439,25 @@
421439
/* End XCConfigurationList section */
422440

423441
/* Begin XCRemoteSwiftPackageReference section */
424-
1A1D51FE28393F0600F2BB1A /* XCRemoteSwiftPackageReference "KMP-NativeCoroutines" */ = {
442+
1AD11A37297BF584001540C5 /* XCRemoteSwiftPackageReference "KMP-NativeCoroutines.git" */ = {
425443
isa = XCRemoteSwiftPackageReference;
426444
repositoryURL = "https://github.com/rickclephas/KMP-NativeCoroutines.git";
427445
requirement = {
428446
kind = exactVersion;
429-
version = 0.12.2;
447+
version = "1.0.0-ALPHA-4";
430448
};
431449
};
432450
/* End XCRemoteSwiftPackageReference section */
433451

434452
/* Begin XCSwiftPackageProductDependency section */
435-
1A1D51FF28393F0600F2BB1A /* KMPNativeCoroutinesAsync */ = {
453+
1AD11A38297BF584001540C5 /* KMPNativeCoroutinesAsync */ = {
436454
isa = XCSwiftPackageProductDependency;
437-
package = 1A1D51FE28393F0600F2BB1A /* XCRemoteSwiftPackageReference "KMP-NativeCoroutines" */;
455+
package = 1AD11A37297BF584001540C5 /* XCRemoteSwiftPackageReference "KMP-NativeCoroutines.git" */;
438456
productName = KMPNativeCoroutinesAsync;
439457
};
440-
1A1D520128393F0600F2BB1A /* KMPNativeCoroutinesCore */ = {
458+
1AD11A3A297BF584001540C5 /* KMPNativeCoroutinesCore */ = {
441459
isa = XCSwiftPackageProductDependency;
442-
package = 1A1D51FE28393F0600F2BB1A /* XCRemoteSwiftPackageReference "KMP-NativeCoroutines" */;
460+
package = 1AD11A37297BF584001540C5 /* XCRemoteSwiftPackageReference "KMP-NativeCoroutines.git" */;
443461
productName = KMPNativeCoroutinesCore;
444462
};
445463
/* End XCSwiftPackageProductDependency section */

ios/GalwayBusAppSwiftUI/GalwayBusAppSwiftUI.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)