From fa2d270a098736f1b41a0ee3d43a1cffcef34049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Herculano?= Date: Thu, 17 Oct 2024 09:51:38 +0200 Subject: [PATCH 1/3] update plugins and dependencies --- core/build.gradle.kts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 352015a..bc24118 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -7,7 +7,8 @@ plugins { kotlin("plugin.serialization") version "1.9.25" id("com.github.ben-manes.versions") version "0.51.0" id("com.android.library") version "8.3.2" - id("com.github.gmazzo.buildconfig") version "5.3.5" + id("com.github.gmazzo.buildconfig") version "5.5.0" + id("name.remal.check-dependency-updates") version "1.5.0" id("maven-publish") id("signing") } @@ -68,8 +69,8 @@ kotlin { sourceSets { val ktorVersion = "2.3.12" val coroutinesVersion = "1.8.1" - val settingsVersion = "1.1.1" - val dataTimeVersion = "0.6.0" + val settingsVersion = "1.2.0" + val dataTimeVersion = "0.6.1" val commonMain by getting { dependencies { implementation("com.russhwolf:multiplatform-settings-no-arg:$settingsVersion") From 1b136c741a72a2a34decca04f916965ce664b7de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Herculano?= Date: Thu, 17 Oct 2024 10:17:43 +0200 Subject: [PATCH 2/3] update kotlin, ktor and gradle --- core/SPMobileCore.podspec | 8 ++++++-- core/build.gradle.kts | 19 ++++++++----------- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/core/SPMobileCore.podspec b/core/SPMobileCore.podspec index e3af62c..c2b88b6 100644 --- a/core/SPMobileCore.podspec +++ b/core/SPMobileCore.podspec @@ -8,8 +8,8 @@ Pod::Spec.new do |spec| spec.summary = 'The internal Network & Data layers used by our mobile SDKs' spec.vendored_frameworks = 'build/cocoapods/framework/SPMobileCore.framework' spec.libraries = 'c++' - spec.ios.deployment_target = '10.0' - spec.tvos.deployment_target = '10.0' + spec.ios.deployment_target = '10.0' + spec.tvos.deployment_target = '10.0' if !Dir.exist?('build/cocoapods/framework/SPMobileCore.framework') || Dir.empty?('build/cocoapods/framework/SPMobileCore.framework') @@ -23,6 +23,10 @@ Pod::Spec.new do |spec| Alternatively, proper pod installation is performed during Gradle sync in the IDE (if Podfile location is set)" end + spec.xcconfig = { + 'ENABLE_USER_SCRIPT_SANDBOXING' => 'NO', + } + spec.pod_target_xcconfig = { 'KOTLIN_PROJECT_PATH' => ':core', 'PRODUCT_MODULE_NAME' => 'SPMobileCore', diff --git a/core/build.gradle.kts b/core/build.gradle.kts index bc24118..98a060e 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -2,13 +2,12 @@ import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTes import java.io.ByteArrayOutputStream plugins { - kotlin("multiplatform") version "1.9.25" - kotlin("native.cocoapods") version "1.9.25" - kotlin("plugin.serialization") version "1.9.25" + kotlin("multiplatform") version "2.0.21" + kotlin("native.cocoapods") version "2.0.21" + kotlin("plugin.serialization") version "2.0.21" id("com.github.ben-manes.versions") version "0.51.0" - id("com.android.library") version "8.3.2" + id("com.android.library") version "8.7.1" id("com.github.gmazzo.buildconfig") version "5.5.0" - id("name.remal.check-dependency-updates") version "1.5.0" id("maven-publish") id("signing") } @@ -36,10 +35,8 @@ kotlin { androidTarget { publishLibraryVariants("release", "debug") - compilations.all { - kotlinOptions { - jvmTarget = "1.8" - } + compilerOptions { + jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8) } } iosX64() @@ -67,8 +64,8 @@ kotlin { } sourceSets { - val ktorVersion = "2.3.12" - val coroutinesVersion = "1.8.1" + val ktorVersion = "3.0.0" + val coroutinesVersion = "1.9.0" val settingsVersion = "1.2.0" val dataTimeVersion = "0.6.1" val commonMain by getting { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d290d9a..5dffa00 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sun Oct 15 15:32:09 CEST 2023 +#Thu Oct 17 10:14:38 CEST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 161323b868401ee2ba9492e0b1f94b81d74d5c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Herculano?= Date: Thu, 17 Oct 2024 10:32:20 +0200 Subject: [PATCH 3/3] fix deprecation warnings and kotlin 2 compatibility --- .../sourcepoint/mobile_core/DeviceInformation.android.kt | 8 ++++---- .../com/sourcepoint/mobile_core/DeviceInformation.kt | 6 +----- .../sourcepoint/mobile_core/network/SourcepointClient.kt | 9 ++++----- .../mobile_core/network/requests/DefaultRequest.kt | 4 ++-- .../com/sourcepoint/mobile_core/DeviceInformation.ios.kt | 8 ++++---- .../sourcepoint/mobile_core/DeviceInformation.tvos.kt | 8 ++++---- 6 files changed, 19 insertions(+), 24 deletions(-) diff --git a/core/src/androidMain/kotlin/com/sourcepoint/mobile_core/DeviceInformation.android.kt b/core/src/androidMain/kotlin/com/sourcepoint/mobile_core/DeviceInformation.android.kt index 5ae60f8..9058418 100644 --- a/core/src/androidMain/kotlin/com/sourcepoint/mobile_core/DeviceInformation.android.kt +++ b/core/src/androidMain/kotlin/com/sourcepoint/mobile_core/DeviceInformation.android.kt @@ -2,8 +2,8 @@ package com.sourcepoint.mobile_core import android.os.Build -actual class DeviceInformationConcrete actual constructor() : DeviceInformation { - override val osName: OSName = OSName.Android - override val osVersion = Build.VERSION.SDK_INT.toString() - override val deviceFamily = Build.MODEL ?: "model-unknown" +actual class DeviceInformation actual constructor() { + actual val osName: OSName = OSName.Android + actual val osVersion = Build.VERSION.SDK_INT.toString() + actual val deviceFamily = Build.MODEL ?: "model-unknown" } diff --git a/core/src/commonMain/kotlin/com/sourcepoint/mobile_core/DeviceInformation.kt b/core/src/commonMain/kotlin/com/sourcepoint/mobile_core/DeviceInformation.kt index b1f9428..b1cdc33 100644 --- a/core/src/commonMain/kotlin/com/sourcepoint/mobile_core/DeviceInformation.kt +++ b/core/src/commonMain/kotlin/com/sourcepoint/mobile_core/DeviceInformation.kt @@ -6,12 +6,8 @@ enum class OSName { Android } -interface DeviceInformation { +expect class DeviceInformation() { val osName: OSName val osVersion: String val deviceFamily: String } - -expect class DeviceInformationConcrete(): DeviceInformation - -val Device = DeviceInformationConcrete() diff --git a/core/src/commonMain/kotlin/com/sourcepoint/mobile_core/network/SourcepointClient.kt b/core/src/commonMain/kotlin/com/sourcepoint/mobile_core/network/SourcepointClient.kt index 6b88f0e..74eb5a9 100644 --- a/core/src/commonMain/kotlin/com/sourcepoint/mobile_core/network/SourcepointClient.kt +++ b/core/src/commonMain/kotlin/com/sourcepoint/mobile_core/network/SourcepointClient.kt @@ -1,7 +1,6 @@ package com.sourcepoint.mobile_core.network import com.sourcepoint.core.BuildConfig -import com.sourcepoint.mobile_core.Device import com.sourcepoint.mobile_core.DeviceInformation import com.sourcepoint.mobile_core.models.SPError import com.sourcepoint.mobile_core.models.SPNetworkError @@ -88,14 +87,14 @@ class SourcepointClient( expectSuccess = false HttpResponseValidator { validateResponse { response -> - if (response.request.url.pathSegments.contains("custom-metrics")) { + if (response.request.url.segments.contains("custom-metrics")) { return@validateResponse } if (response.status.value !in 200..299) { throw reportErrorAndThrow(SPNetworkError( statusCode = response.status.value, - path = response.request.url.pathSegments.last(), + path = response.request.url.segments.last(), campaignType = null )) } @@ -114,7 +113,7 @@ class SourcepointClient( propertyId, propertyName, httpEngine = null, - device = Device, + device = DeviceInformation(), version = BuildConfig.Version, requestTimeoutInSeconds = requestTimeoutInSeconds ) @@ -130,7 +129,7 @@ class SourcepointClient( propertyId, propertyName, httpEngine = httpEngine, - device = Device, + device = DeviceInformation(), version = BuildConfig.Version, requestTimeoutInSeconds = requestTimeoutInSeconds ) diff --git a/core/src/commonMain/kotlin/com/sourcepoint/mobile_core/network/requests/DefaultRequest.kt b/core/src/commonMain/kotlin/com/sourcepoint/mobile_core/network/requests/DefaultRequest.kt index 8bfba13..1ad752b 100644 --- a/core/src/commonMain/kotlin/com/sourcepoint/mobile_core/network/requests/DefaultRequest.kt +++ b/core/src/commonMain/kotlin/com/sourcepoint/mobile_core/network/requests/DefaultRequest.kt @@ -1,13 +1,13 @@ package com.sourcepoint.mobile_core.network.requests import com.sourcepoint.core.BuildConfig -import com.sourcepoint.mobile_core.Device +import com.sourcepoint.mobile_core.DeviceInformation import kotlinx.serialization.Serializable @Suppress("unused") // properties are used in every request inheriting from DefaultRequest @Serializable open class DefaultRequest { val env = "prod" - val scriptType = "mobile-core-${Device.osName.name}" + val scriptType = "mobile-core-${DeviceInformation().osName.name}" val scriptVersion = BuildConfig.Version } diff --git a/core/src/iosMain/kotlin/com/sourcepoint/mobile_core/DeviceInformation.ios.kt b/core/src/iosMain/kotlin/com/sourcepoint/mobile_core/DeviceInformation.ios.kt index 94c7c79..b7ef68b 100644 --- a/core/src/iosMain/kotlin/com/sourcepoint/mobile_core/DeviceInformation.ios.kt +++ b/core/src/iosMain/kotlin/com/sourcepoint/mobile_core/DeviceInformation.ios.kt @@ -2,8 +2,8 @@ package com.sourcepoint.mobile_core import platform.UIKit.UIDevice -actual class DeviceInformationConcrete actual constructor() : DeviceInformation { - override val osName = OSName.iOS - override val osVersion = UIDevice.currentDevice.systemVersion - override val deviceFamily = UIDevice.currentDevice.name +actual class DeviceInformation actual constructor() { + actual val osName = OSName.iOS + actual val osVersion = UIDevice.currentDevice.systemVersion + actual val deviceFamily = UIDevice.currentDevice.name } diff --git a/core/src/tvosMain/kotlin/com/sourcepoint/mobile_core/DeviceInformation.tvos.kt b/core/src/tvosMain/kotlin/com/sourcepoint/mobile_core/DeviceInformation.tvos.kt index 1e42335..1df819f 100644 --- a/core/src/tvosMain/kotlin/com/sourcepoint/mobile_core/DeviceInformation.tvos.kt +++ b/core/src/tvosMain/kotlin/com/sourcepoint/mobile_core/DeviceInformation.tvos.kt @@ -2,8 +2,8 @@ package com.sourcepoint.mobile_core import platform.UIKit.UIDevice -actual class DeviceInformationConcrete actual constructor() : DeviceInformation { - override val osName: OSName = OSName.tvOS - override val osVersion: String = UIDevice.currentDevice.systemVersion - override val deviceFamily = UIDevice.currentDevice.name +actual class DeviceInformation actual constructor() { + actual val osName: OSName = OSName.tvOS + actual val osVersion: String = UIDevice.currentDevice.systemVersion + actual val deviceFamily = UIDevice.currentDevice.name }