diff --git a/samples/kmp/.gitignore b/samples/kmp/.gitignore index e510fa99de5..987278499e6 100644 --- a/samples/kmp/.gitignore +++ b/samples/kmp/.gitignore @@ -7,4 +7,5 @@ captures .externalNativeBuild .cxx local.properties -xcuserdata \ No newline at end of file +xcuserdata +.kotlin \ No newline at end of file diff --git a/samples/kmp/androidApp/build.gradle.kts b/samples/kmp/androidApp/build.gradle.kts index 44b6129bc02..13f1bc57e07 100644 --- a/samples/kmp/androidApp/build.gradle.kts +++ b/samples/kmp/androidApp/build.gradle.kts @@ -1,25 +1,23 @@ plugins { id("com.android.application") kotlin("android") + kotlin("plugin.compose") } android { namespace = "com.example.kmpsample.android" - compileSdk = 33 + compileSdk = 35 defaultConfig { applicationId = "com.example.kmpsample.android" minSdk = 24 - targetSdk = 33 + targetSdk = 35 versionCode = 1 versionName = "1.0" } buildFeatures { compose = true } - composeOptions { - kotlinCompilerExtensionVersion = "1.5.12" - } - packagingOptions { + packaging { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" } @@ -30,20 +28,20 @@ android { } } compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = "1.8" + jvmTarget = "17" } } dependencies { implementation(project(":shared")) - implementation("androidx.compose.ui:ui:1.3.1") - implementation("androidx.compose.ui:ui-tooling:1.3.1") - implementation("androidx.compose.ui:ui-tooling-preview:1.3.1") - implementation("androidx.compose.foundation:foundation:1.3.1") - implementation("androidx.compose.material:material:1.3.1") - implementation("androidx.activity:activity-compose:1.6.1") + implementation("androidx.compose.ui:ui:1.7.5") + implementation("androidx.compose.ui:ui-tooling:1.7.5") + implementation("androidx.compose.ui:ui-tooling-preview:1.7.5") + implementation("androidx.compose.foundation:foundation:1.7.5") + implementation("androidx.compose.material:material:1.7.5") + implementation("androidx.activity:activity-compose:1.9.3") } \ No newline at end of file diff --git a/samples/kmp/androidApp/src/main/java/com/example/kmpsample/android/MainActivity.kt b/samples/kmp/androidApp/src/main/java/com/example/kmpsample/android/MainActivity.kt index 1ab49166253..9eb52d17666 100644 --- a/samples/kmp/androidApp/src/main/java/com/example/kmpsample/android/MainActivity.kt +++ b/samples/kmp/androidApp/src/main/java/com/example/kmpsample/android/MainActivity.kt @@ -3,11 +3,17 @@ package com.example.kmpsample.android import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material.* +import androidx.compose.foundation.layout.padding +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Surface +import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp import com.example.kmpsample.Sample class MainActivity : ComponentActivity() { @@ -28,7 +34,14 @@ class MainActivity : ComponentActivity() { @Composable fun GreetingView(text: String) { - Text(text = text) + Column( + modifier = Modifier.padding(16.dp), + verticalArrangement = Arrangement.Center + ) { + Text( + text = text + ) + } } @Preview diff --git a/samples/kmp/build.gradle.kts b/samples/kmp/build.gradle.kts index ded20aa5f71..48caac9cdc5 100644 --- a/samples/kmp/build.gradle.kts +++ b/samples/kmp/build.gradle.kts @@ -1,11 +1,11 @@ plugins { - //trick: for the same plugin versions in all sub-modules - id("com.android.application").version("7.4.1").apply(false) - id("com.android.library").version("7.4.1").apply(false) - kotlin("android").version("1.9.23").apply(false) - kotlin("multiplatform").version("1.9.23").apply(false) + id("com.android.application").version("8.7.3").apply(false) + id("com.android.library").version("8.7.3").apply(false) + kotlin("android").version("2.1.0").apply(false) + kotlin("plugin.compose").version("2.1.0").apply(false) + kotlin("multiplatform").version("2.1.0").apply(false) } tasks.register("clean", Delete::class) { - delete(rootProject.buildDir) + delete(rootProject.layout.buildDirectory) } diff --git a/samples/kmp/gradle/wrapper/gradle-wrapper.jar b/samples/kmp/gradle/wrapper/gradle-wrapper.jar index 249e5832f09..2c3521197d7 100644 Binary files a/samples/kmp/gradle/wrapper/gradle-wrapper.jar and b/samples/kmp/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/kmp/gradle/wrapper/gradle-wrapper.properties b/samples/kmp/gradle/wrapper/gradle-wrapper.properties index e1bef7e873c..df97d72b8b9 100644 --- a/samples/kmp/gradle/wrapper/gradle-wrapper.properties +++ b/samples/kmp/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/samples/kmp/gradlew b/samples/kmp/gradlew index a69d9cb6c20..f5feea6d6b1 100755 --- a/samples/kmp/gradlew +++ b/samples/kmp/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +82,12 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +134,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,11 +201,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/samples/kmp/gradlew.bat b/samples/kmp/gradlew.bat index 53a6b238d41..9b42019c791 100644 --- a/samples/kmp/gradlew.bat +++ b/samples/kmp/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -26,6 +28,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -42,11 +45,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -56,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/samples/kmp/iosApp/Podfile b/samples/kmp/iosApp/Podfile index aff9c517b20..057b34cefc7 100644 --- a/samples/kmp/iosApp/Podfile +++ b/samples/kmp/iosApp/Podfile @@ -1,5 +1,5 @@ target 'iosApp' do use_frameworks! - platform :ios, '14.1' + platform :ios, '18' pod 'shared', :path => '../shared' end \ No newline at end of file diff --git a/samples/kmp/iosApp/Podfile.lock b/samples/kmp/iosApp/Podfile.lock index 3c203ef8291..635b12c2a1b 100644 --- a/samples/kmp/iosApp/Podfile.lock +++ b/samples/kmp/iosApp/Podfile.lock @@ -22,10 +22,10 @@ EXTERNAL SOURCES: :path: "../shared" SPEC CHECKSUMS: - shared: 973e5c894781ebff8382176ea25326e62f08b171 + shared: b2f1e46b5dd33f47e8467e5b4aab48df66e69197 SwiftProtobuf: 59d9ea2eb5f84b509f32d170a65f3348ae758f1e TrustWalletCore: 53f09313edb1c010de78314d023c67d2d4654864 -PODFILE CHECKSUM: f282da88f39e69507b0a255187c8a6b644477756 +PODFILE CHECKSUM: 81dfb0baa6aaca56ab433de92eef03723c36f7f9 -COCOAPODS: 1.11.3 +COCOAPODS: 1.15.2 diff --git a/samples/kmp/shared/build.gradle.kts b/samples/kmp/shared/build.gradle.kts index c27215519a7..2fc56d2a94d 100644 --- a/samples/kmp/shared/build.gradle.kts +++ b/samples/kmp/shared/build.gradle.kts @@ -1,4 +1,5 @@ import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform +import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { kotlin("multiplatform") @@ -7,10 +8,14 @@ plugins { } kotlin { - android { + jvmToolchain(17) + + androidTarget { compilations.all { - kotlinOptions { - jvmTarget = "1.8" + compileTaskProvider.configure { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_17) + } } } } @@ -22,7 +27,7 @@ kotlin { summary = "Some description for the Shared Module" homepage = "Link to the Shared Module homepage" version = "1.0" - ios.deploymentTarget = "14.1" + ios.deploymentTarget = "18" dependencies { pod("TrustWalletCore", moduleName = "WalletCore") } @@ -87,9 +92,8 @@ kotlin { android { namespace = "com.example.kmpsample" - compileSdk = 33 + compileSdk = 35 defaultConfig { minSdk = 24 - targetSdk = 33 } } diff --git a/samples/kmp/shared/shared.podspec b/samples/kmp/shared/shared.podspec index 9673fb1edda..434dc653239 100644 --- a/samples/kmp/shared/shared.podspec +++ b/samples/kmp/shared/shared.podspec @@ -8,9 +8,24 @@ Pod::Spec.new do |spec| spec.summary = 'Some description for the Shared Module' spec.vendored_frameworks = 'build/cocoapods/framework/shared.framework' spec.libraries = 'c++' - spec.ios.deployment_target = '14.1' + spec.ios.deployment_target = '18' spec.dependency 'TrustWalletCore' + if !Dir.exist?('build/cocoapods/framework/shared.framework') || Dir.empty?('build/cocoapods/framework/shared.framework') + raise " + + Kotlin framework 'shared' doesn't exist yet, so a proper Xcode project can't be generated. + 'pod install' should be executed after running ':generateDummyFramework' Gradle task: + + ./gradlew :shared:generateDummyFramework + + 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' => ':shared', 'PRODUCT_MODULE_NAME' => 'shared', diff --git a/samples/kmp/shared/src/commonMain/kotlin/com/example/kmpsample/Sample.kt b/samples/kmp/shared/src/commonMain/kotlin/com/example/kmpsample/Sample.kt index c6ebdbc99a9..044cc076266 100644 --- a/samples/kmp/shared/src/commonMain/kotlin/com/example/kmpsample/Sample.kt +++ b/samples/kmp/shared/src/commonMain/kotlin/com/example/kmpsample/Sample.kt @@ -1,5 +1,7 @@ package com.example.kmpsample -import com.trustwallet.core.* + +import com.trustwallet.core.CoinType +import com.trustwallet.core.HDWallet class Sample { private val platform: Platform = getPlatform() @@ -7,11 +9,11 @@ class Sample { fun greet(): String { var log = "Wallet Core KMP on platform: ${platform.name}!\n\n" val wallet = HDWallet(256, "") - log += "Created mnemonic: ${wallet.mnemonic}\n" + log += "Created mnemonic: ${wallet.mnemonic}\n\n" val btcAddress = wallet.getAddressForCoin(CoinType.Bitcoin) + log += "Bitcoin address: ${btcAddress}\n\n" val ethAddress = wallet.getAddressForCoin(CoinType.Ethereum) - log += "Bitcoin address: ${btcAddress}\n" - log += "Ethereum address: ${ethAddress}\n" + log += "Ethereum address: ${ethAddress}\n\n" return log } } \ No newline at end of file