diff --git a/.github/workflows/compilation-check.yml b/.github/workflows/compilation-check.yml
index 5d4b39c..1027b5e 100644
--- a/.github/workflows/compilation-check.yml
+++ b/.github/workflows/compilation-check.yml
@@ -12,13 +12,11 @@ jobs:
steps:
- uses: actions/checkout@v1
- - name: Set up JDK 11
+ - name: Set up JDK 17
uses: actions/setup-java@v1
with:
- java-version: 11
+ java-version: 17
- name: Check runtime
- run: ./gradlew build publishToMavenLocal syncMultiPlatformLibraryDebugFrameworkIosX64
- - name: Install pods
- run: cd sample/ios-app && pod install
- - name: build ios sample
- run: cd sample/ios-app && set -o pipefail && xcodebuild -scheme TestProj -workspace TestProj.xcworkspace -configuration Debug -sdk iphonesimulator -arch x86_64 build CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO | xcpretty
+ run: ./local-check.sh
+ - name: Check sample
+ run: cd sample && ./local-check.sh
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 380861e..bcaabf5 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -20,10 +20,10 @@ jobs:
SIGNING_KEY: ${{ secrets.GPG_KEY_CONTENTS }}
steps:
- uses: actions/checkout@v1
- - name: Set up JDK 11
+ - name: Set up JDK 17
uses: actions/setup-java@v1
with:
- java-version: 11
+ java-version: 17
- name: Publish
run: ./gradlew publish
release:
@@ -41,4 +41,4 @@ jobs:
tag_name: release/${{ github.event.inputs.version }}
release_name: ${{ github.event.inputs.version }}
body: "Will be filled later"
- draft: true
\ No newline at end of file
+ draft: true
diff --git a/README.md b/README.md
index a852011..a471b3d 100755
--- a/README.md
+++ b/README.md
@@ -36,10 +36,10 @@ allprojects {
project build.gradle
```groovy
dependencies {
- commonMainApi("dev.icerock.moko:geo:0.6.0")
+ commonMainApi("dev.icerock.moko:geo:0.7.0")
// Compose Multiplatform
- commonMainApi("dev.icerock.moko:geo-compose:0.6.0")
+ commonMainApi("dev.icerock.moko:geo-compose:0.7.0")
}
```
@@ -104,6 +104,10 @@ The `develop` branch is pushed to `master` on release.
For more details on contributing please see the [contributing guide](CONTRIBUTING.md).
+Before send PR please run checks on local:
+- `./local-check.sh` in root of repository
+- `./local-check.sh` in `sample` directory
+
## License
Copyright 2019 IceRock MAG Inc.
diff --git a/geo-compose/build.gradle.kts b/geo-compose/build.gradle.kts
index 5422fa1..32458a5 100644
--- a/geo-compose/build.gradle.kts
+++ b/geo-compose/build.gradle.kts
@@ -16,6 +16,21 @@ android {
defaultConfig {
minSdk = 21
}
+
+ compileOptions {
+ sourceCompatibility(JavaVersion.VERSION_17)
+ targetCompatibility(JavaVersion.VERSION_17)
+ }
+}
+
+kotlin {
+ androidTarget {
+ compilations.all {
+ kotlinOptions {
+ jvmTarget = JavaVersion.VERSION_17.majorVersion
+ }
+ }
+ }
}
dependencies {
diff --git a/geo-compose/src/androidMain/kotlin/dev/icerock/moko/geo/compose/BindLocationTrackerEffect.android.kt b/geo-compose/src/androidMain/kotlin/dev/icerock/moko/geo/compose/BindLocationTrackerEffect.android.kt
index 5ff264a..6c2942a 100644
--- a/geo-compose/src/androidMain/kotlin/dev/icerock/moko/geo/compose/BindLocationTrackerEffect.android.kt
+++ b/geo-compose/src/androidMain/kotlin/dev/icerock/moko/geo/compose/BindLocationTrackerEffect.android.kt
@@ -4,25 +4,18 @@
package dev.icerock.moko.geo.compose
-import android.content.Context
+import androidx.activity.ComponentActivity
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.platform.LocalContext
-import androidx.compose.ui.platform.LocalLifecycleOwner
-import androidx.fragment.app.FragmentActivity
-import androidx.fragment.app.FragmentManager
-import androidx.lifecycle.LifecycleOwner
import dev.icerock.moko.geo.LocationTracker
@Suppress("FunctionNaming")
@Composable
actual fun BindLocationTrackerEffect(locationTracker: LocationTracker) {
- val lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current
- val context: Context = LocalContext.current
+ val activity: ComponentActivity = LocalContext.current as ComponentActivity
- LaunchedEffect(locationTracker, lifecycleOwner, context) {
- val fragmentManager: FragmentManager = (context as FragmentActivity).supportFragmentManager
-
- locationTracker.bind(lifecycleOwner.lifecycle, context, fragmentManager)
+ LaunchedEffect(activity) {
+ locationTracker.bind(activity)
}
}
diff --git a/geo/build.gradle.kts b/geo/build.gradle.kts
index bc42fa7..f42ff0c 100644
--- a/geo/build.gradle.kts
+++ b/geo/build.gradle.kts
@@ -10,6 +10,25 @@ plugins {
id("kotlin-parcelize")
}
+android {
+ namespace = "dev.icerock.moko.geo"
+
+ compileOptions {
+ sourceCompatibility(JavaVersion.VERSION_17)
+ targetCompatibility(JavaVersion.VERSION_17)
+ }
+}
+
+kotlin {
+ androidTarget {
+ compilations.all {
+ kotlinOptions {
+ jvmTarget = JavaVersion.VERSION_17.majorVersion
+ }
+ }
+ }
+}
+
dependencies {
commonMainImplementation(libs.coroutines)
diff --git a/geo/src/androidMain/AndroidManifest.xml b/geo/src/androidMain/AndroidManifest.xml
index 2560f46..769b825 100755
--- a/geo/src/androidMain/AndroidManifest.xml
+++ b/geo/src/androidMain/AndroidManifest.xml
@@ -1,6 +1,5 @@
-
+
-
\ No newline at end of file
+
diff --git a/geo/src/androidMain/kotlin/dev/icerock/moko/geo/LocationTracker.kt b/geo/src/androidMain/kotlin/dev/icerock/moko/geo/LocationTracker.kt
index 93d5982..69405fe 100644
--- a/geo/src/androidMain/kotlin/dev/icerock/moko/geo/LocationTracker.kt
+++ b/geo/src/androidMain/kotlin/dev/icerock/moko/geo/LocationTracker.kt
@@ -5,9 +5,8 @@
package dev.icerock.moko.geo
import android.annotation.SuppressLint
-import android.content.Context
import android.os.Build
-import androidx.fragment.app.FragmentManager
+import androidx.activity.ComponentActivity
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
@@ -30,7 +29,7 @@ import kotlinx.coroutines.launch
actual class LocationTracker(
actual val permissionsController: PermissionsController,
interval: Long = 1000,
- priority: Int = LocationRequest.PRIORITY_HIGH_ACCURACY
+ priority: Int = LocationRequest.PRIORITY_HIGH_ACCURACY,
) : LocationCallback() {
private var locationProviderClient: FusedLocationProviderClient? = null
private var isStarted: Boolean = false
@@ -42,17 +41,17 @@ actual class LocationTracker(
private val extendedLocationsChannel = Channel(Channel.CONFLATED)
private val trackerScope = CoroutineScope(Dispatchers.Main)
- fun bind(lifecycle: Lifecycle, context: Context, fragmentManager: FragmentManager) {
- permissionsController.bind(lifecycle, fragmentManager)
+ fun bind(activity: ComponentActivity) {
+ permissionsController.bind(activity)
- locationProviderClient = LocationServices.getFusedLocationProviderClient(context)
+ locationProviderClient = LocationServices.getFusedLocationProviderClient(activity)
@SuppressLint("MissingPermission")
if (isStarted) {
locationProviderClient?.requestLocationUpdates(locationRequest, this, null)
}
- lifecycle.addObserver(object : LifecycleObserver {
+ activity.lifecycle.addObserver(object : LifecycleObserver {
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
fun onDestroy() {
locationProviderClient?.removeLocationUpdates(this@LocationTracker)
@@ -66,14 +65,23 @@ actual class LocationTracker(
val lastLocation = locationResult.lastLocation ?: return
- val speedAccuracy = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) null
- else lastLocation.speedAccuracyMetersPerSecond.toDouble()
+ val speedAccuracy = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
+ null
+ } else {
+ lastLocation.speedAccuracyMetersPerSecond.toDouble()
+ }
- val bearingAccuracy = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) null
- else lastLocation.bearingAccuracyDegrees.toDouble()
+ val bearingAccuracy = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
+ null
+ } else {
+ lastLocation.bearingAccuracyDegrees.toDouble()
+ }
- val verticalAccuracy = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) null
- else lastLocation.verticalAccuracyMeters.toDouble()
+ val verticalAccuracy = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
+ null
+ } else {
+ lastLocation.verticalAccuracyMeters.toDouble()
+ }
val latLng = LatLng(
lastLocation.latitude,
diff --git a/geo/src/iosX64Main/kotlin/dev/icerock/moko/geo/Tracker.kt b/geo/src/iosX64Main/kotlin/dev/icerock/moko/geo/Tracker.kt
index 385f427..a4568e4 100644
--- a/geo/src/iosX64Main/kotlin/dev/icerock/moko/geo/Tracker.kt
+++ b/geo/src/iosX64Main/kotlin/dev/icerock/moko/geo/Tracker.kt
@@ -4,6 +4,7 @@
package dev.icerock.moko.geo
+import kotlinx.cinterop.ExperimentalForeignApi
import kotlinx.cinterop.useContents
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.Channel
@@ -16,9 +17,11 @@ import platform.Foundation.NSLog
import platform.Foundation.timeIntervalSince1970
import platform.UIKit.UIDevice
import platform.darwin.NSObject
+import kotlin.experimental.ExperimentalNativeApi
import kotlin.native.ref.WeakReference
import kotlin.time.Duration.Companion.seconds
+@OptIn(ExperimentalNativeApi::class, ExperimentalForeignApi::class)
internal actual class Tracker actual constructor(
locationsChannel: Channel,
extendedLocationsChannel: Channel,
@@ -37,8 +40,11 @@ internal actual class Tracker actual constructor(
locations.forEach { location ->
val courseAccuracy =
- if (UIDevice.currentDevice.systemVersion.compareTo("13.4") < 0) null
- else location.courseAccuracy
+ if (UIDevice.currentDevice.systemVersion.compareTo("13.4") < 0) {
+ null
+ } else {
+ location.courseAccuracy
+ }
val latLng = location.coordinate().useContents {
LatLng(
diff --git a/gradle.properties b/gradle.properties
index 92088cf..a98e2ff 100755
--- a/gradle.properties
+++ b/gradle.properties
@@ -7,9 +7,9 @@ kotlin.mpp.androidSourceSetLayoutVersion=2
android.useAndroidX=true
-moko.android.targetSdk=33
-moko.android.compileSdk=33
-moko.android.minSdk=16
+moko.android.targetSdk=34
+moko.android.compileSdk=34
+moko.android.minSdk=21
moko.publish.name=MOKO geo
moko.publish.description=Geolocation access for mobile (android & ios) Kotlin Multiplatform development
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index c686586..6979910 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,15 +1,15 @@
[versions]
-kotlinVersion = "1.8.10"
+kotlinVersion = "1.9.24"
androidAppCompatVersion = "1.6.1"
androidLifecycleVersion = "2.2.0"
-playServicesLocationVersion = "21.0.1"
-coroutinesVersion = "1.6.4"
-composeJetBrainsVersion = "1.3.1"
-mokoParcelizeVersion = "0.8.0"
-mokoPermissionsVersion = "0.15.0"
-mokoMvvmVersion = "0.16.0"
-mokoGeoVersion = "0.6.0"
-mokoResourcesVersion = "0.21.1"
+playServicesLocationVersion = "21.3.0"
+coroutinesVersion = "1.8.1"
+composeJetBrainsVersion = "1.6.11"
+mokoParcelizeVersion = "0.9.0"
+mokoPermissionsVersion = "0.18.0"
+mokoMvvmVersion = "0.16.1"
+mokoGeoVersion = "0.7.0"
+mokoResourcesVersion = "0.24.1"
[libraries]
appCompat = { module = "androidx.appcompat:appcompat", version.ref = "androidAppCompatVersion" }
@@ -26,10 +26,9 @@ mokoResources = { module = "dev.icerock.moko:resources", version.ref = "mokoReso
kotlinGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlinVersion" }
androidGradlePlugin = { module = "com.android.tools.build:gradle", version = "7.4.2" }
-googleServicesGradlePlugin = { module = "com.google.gms:google-services", version = "4.3.15" }
-firebaseGradlePlugin = { module = "com.google.firebase:firebase-crashlytics-gradle", version = "2.9.4" }
-mokoGradlePlugin = { module = "dev.icerock.moko:moko-gradle-plugin", version = "0.2.0" }
+googleServicesGradlePlugin = { module = "com.google.gms:google-services", version = "4.4.2" }
+mokoGradlePlugin = { module = "dev.icerock.moko:moko-gradle-plugin", version = "0.3.0" }
mobileMultiplatformGradlePlugin = { module = "dev.icerock:mobile-multiplatform", version = "0.14.2" }
kotlinSerializationGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlinVersion" }
composeJetBrainsGradlePlugin = { module = "org.jetbrains.compose:compose-gradle-plugin", version.ref = "composeJetBrainsVersion" }
-detektGradlePlugin = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version = "1.22.0" }
+detektGradlePlugin = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version = "1.23.6" }
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index e708b1c..943f0cb 100755
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 774fae8..0d18421 100755
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index 4f906e0..65dcd68 100755
--- a/gradlew
+++ b/gradlew
@@ -1,7 +1,7 @@
-#!/usr/bin/env sh
+#!/bin/sh
#
-# Copyright 2015 the original author or authors.
+# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -17,67 +17,101 @@
#
##############################################################################
-##
-## Gradle start up script for UN*X
-##
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
##############################################################################
# Attempt to set APP_HOME
+
# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# 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"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
+MAX_FD=maximum
warn () {
echo "$*"
-}
+} >&2
die () {
echo
echo "$*"
echo
exit 1
-}
+} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
+ JAVACMD=$JAVA_HOME/jre/sh/java
else
- JAVACMD="$JAVA_HOME/bin/java"
+ JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
- JAVACMD="java"
+ 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.
Please set the JAVA_HOME variable in your environment to match the
@@ -106,80 +140,105 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
+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=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=SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
fi
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
-if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
fi
- i=`expr $i + 1`
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
done
- case $i in
- 0) set -- ;;
- 1) set -- "$args0" ;;
- 2) set -- "$args0" "$args1" ;;
- 3) set -- "$args0" "$args1" "$args2" ;;
- 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
fi
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=`save "$@"`
+# 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.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index 107acd3..93e3f59 100755
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -14,7 +14,7 @@
@rem limitations under the License.
@rem
-@if "%DEBUG%" == "" @echo off
+@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto execute
+if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end
@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
+if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
diff --git a/local-check.sh b/local-check.sh
new file mode 100755
index 0000000..2d3d9c2
--- /dev/null
+++ b/local-check.sh
@@ -0,0 +1,18 @@
+set -e
+
+log() {
+ echo "\033[0;32m> $1\033[0m"
+}
+
+# run gradle tasks in faster order to receive faster feedback
+./gradlew detekt
+log "runtime detekt success"
+
+./gradlew assembleDebug
+log "runtime android success"
+
+./gradlew compileKotlinIosX64
+log "runtime ios success"
+
+./gradlew build publishToMavenLocal
+log "runtime build and publish success"
diff --git a/sample/android-app/build.gradle.kts b/sample/android-app/build.gradle.kts
index cde7c8e..6a3cea1 100644
--- a/sample/android-app/build.gradle.kts
+++ b/sample/android-app/build.gradle.kts
@@ -5,6 +5,8 @@ plugins {
}
android {
+ namespace = "com.icerockdev.app"
+
buildFeatures.dataBinding = true
defaultConfig {
@@ -13,6 +15,17 @@ android {
versionCode = 1
versionName = "0.1.0"
+
+ minSdk = 24
+ }
+
+ compileOptions {
+ sourceCompatibility(JavaVersion.VERSION_17)
+ targetCompatibility(JavaVersion.VERSION_17)
+ }
+
+ kotlinOptions {
+ jvmTarget = JavaVersion.VERSION_17.majorVersion
}
}
diff --git a/sample/android-app/src/main/AndroidManifest.xml b/sample/android-app/src/main/AndroidManifest.xml
index 2c20053..eec007e 100755
--- a/sample/android-app/src/main/AndroidManifest.xml
+++ b/sample/android-app/src/main/AndroidManifest.xml
@@ -1,9 +1,10 @@
+ xmlns:tools="http://schemas.android.com/tools">
+
+
() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
- viewModel.locationTracker.bind(lifecycle, this, supportFragmentManager)
+ viewModel.locationTracker.bind(activity = this)
}
}
diff --git a/sample/ios-app/Podfile b/sample/ios-app/Podfile
index 451523a..d45e9eb 100644
--- a/sample/ios-app/Podfile
+++ b/sample/ios-app/Podfile
@@ -4,7 +4,7 @@ source 'https://cdn.cocoapods.org/'
inhibit_all_warnings!
use_frameworks!
-platform :ios, '11.0'
+platform :ios, '12.0'
target 'TestProj' do
# MultiPlatformLibrary
diff --git a/sample/ios-app/Podfile.lock b/sample/ios-app/Podfile.lock
index da80df9..06a4a52 100644
--- a/sample/ios-app/Podfile.lock
+++ b/sample/ios-app/Podfile.lock
@@ -9,8 +9,8 @@ EXTERNAL SOURCES:
:path: "../mpp-library"
SPEC CHECKSUMS:
- MultiPlatformLibrary: 176fb8ade516666cd47e93de1b71ba0441a541bb
+ MultiPlatformLibrary: e90154651f2068415822dc37193df246c92e7b2a
-PODFILE CHECKSUM: 1b71d80cc7f81711555670bda957555a8503b31a
+PODFILE CHECKSUM: f02f071e13bda07c0fef717fc00fab294cd42253
-COCOAPODS: 1.10.0
+COCOAPODS: 1.15.2
diff --git a/sample/ios-app/TestProj.xcodeproj/project.pbxproj b/sample/ios-app/TestProj.xcodeproj/project.pbxproj
index f292213..7375c83 100644
--- a/sample/ios-app/TestProj.xcodeproj/project.pbxproj
+++ b/sample/ios-app/TestProj.xcodeproj/project.pbxproj
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 51;
+ objectVersion = 54;
objects = {
/* Begin PBXBuildFile section */
@@ -273,6 +273,7 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 4VU932NX78;
INFOPLIST_FILE = src/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 16.0;
PRODUCT_BUNDLE_IDENTIFIER = dev.icerock.moko.sample.geo;
PRODUCT_NAME = "moko-geo";
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -291,6 +292,7 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 4VU932NX78;
INFOPLIST_FILE = src/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 16.0;
PRODUCT_BUNDLE_IDENTIFIER = dev.icerock.moko.sample.geo;
PRODUCT_NAME = "moko-geo";
PROVISIONING_PROFILE_SPECIFIER = "";
diff --git a/sample/local-check.sh b/sample/local-check.sh
new file mode 100755
index 0000000..8db5664
--- /dev/null
+++ b/sample/local-check.sh
@@ -0,0 +1,34 @@
+#
+# Copyright 2023 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
+#
+
+set -e
+
+log() {
+ echo "\033[0;32m> $1\033[0m"
+}
+
+./gradlew clean assembleDebug
+log "sample android success"
+
+if ! command -v xcodebuild &> /dev/null
+then
+ log "xcodebuild could not be found, skip ios checks"
+
+ ./gradlew build
+ log "sample full build success"
+else
+ ./gradlew clean compileKotlinIosX64
+ log "sample ios success"
+
+ ./gradlew clean build syncMultiPlatformLibraryDebugFrameworkIosX64
+ log "sample clean build success"
+
+ (
+ cd ios-app &&
+ pod install &&
+ set -o pipefail &&
+ xcodebuild -scheme TestProj -workspace TestProj.xcworkspace -configuration Debug -sdk iphonesimulator -arch x86_64 build CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO | xcpretty
+ )
+ log "sample ios xcode success"
+fi
diff --git a/sample/mpp-library/MultiPlatformLibrary.podspec b/sample/mpp-library/MultiPlatformLibrary.podspec
index f3870e5..2018f59 100644
--- a/sample/mpp-library/MultiPlatformLibrary.podspec
+++ b/sample/mpp-library/MultiPlatformLibrary.podspec
@@ -11,12 +11,14 @@ Pod::Spec.new do |spec|
spec.libraries = "c++"
spec.module_name = "#{spec.name}_umbrella"
+ spec.ios.deployment_target = '12.0'
+ spec.osx.deployment_target = '10.6'
+
spec.pod_target_xcconfig = {
- 'MPP_LIBRARY_NAME' => 'MultiPlatformLibrary',
- 'GRADLE_TASK[sdk=iphonesimulator*][config=*ebug]' => 'syncMultiPlatformLibraryDebugFrameworkIosX64',
- 'GRADLE_TASK[sdk=iphonesimulator*][config=*elease]' => 'syncMultiPlatformLibraryReleaseFrameworkIosX64',
- 'GRADLE_TASK[sdk=iphoneos*][config=*ebug]' => 'syncMultiPlatformLibraryDebugFrameworkIosArm64',
- 'GRADLE_TASK[sdk=iphoneos*][config=*elease]' => 'syncMultiPlatformLibraryReleaseFrameworkIosArm64'
+ 'KOTLIN_FRAMEWORK_BUILD_TYPE[config=*ebug]' => 'debug',
+ 'KOTLIN_FRAMEWORK_BUILD_TYPE[config=*elease]' => 'release',
+ 'CURENT_SDK[sdk=iphoneos*]' => 'iphoneos',
+ 'CURENT_SDK[sdk=iphonesimulator*]' => 'iphonesimulator',
}
spec.script_phases = [
@@ -24,12 +26,31 @@ Pod::Spec.new do |spec|
:name => 'Compile Kotlin/Native',
:execution_position => :before_compile,
:shell_path => '/bin/sh',
- #:output_files => ['$TARGET_BUILD_DIR/$PRODUCT_NAME.framework/$PRODUCT_NAME'],
:script => <<-SCRIPT
-MPP_PROJECT_ROOT="$SRCROOT/../../mpp-library"
+if [ "$KOTLIN_FRAMEWORK_BUILD_TYPE" == "debug" ]; then
+ CONFIG="Debug"
+else
+ CONFIG="Release"
+fi
-MPP_OUTPUT_DIR="$MPP_PROJECT_ROOT/build/cocoapods/framework"
-MPP_OUTPUT_NAME="$MPP_OUTPUT_DIR/#{spec.name}.framework"
+if [ "$CURENT_SDK" == "iphoneos" ]; then
+ TARGET="Ios"
+ ARCH="Arm64"
+elif [ "$CURENT_SDK" == "iphonesimulator" ]; then
+ if [ "$ARCHS" == "arm64" ]; then
+ TARGET="IosSimulator"
+ ARCH="Arm64"
+ else
+ TARGET="Ios"
+ ARCH="X64"
+ fi
+else
+ echo "unsupported $CURENT_SDK"
+ exit 1
+fi
+
+MPP_PROJECT_ROOT="$SRCROOT/../../mpp-library"
+GRADLE_TASK="syncMultiPlatformLibrary${CONFIG}Framework${TARGET}${ARCH}"
"$MPP_PROJECT_ROOT/../gradlew" -p "$MPP_PROJECT_ROOT" "$GRADLE_TASK"
SCRIPT
diff --git a/sample/mpp-library/build.gradle.kts b/sample/mpp-library/build.gradle.kts
index c4d3004..01bc714 100644
--- a/sample/mpp-library/build.gradle.kts
+++ b/sample/mpp-library/build.gradle.kts
@@ -4,6 +4,25 @@ plugins {
id("dev.icerock.moko.gradle.detekt")
}
+android {
+ namespace = "com.icerockdev.library"
+
+ compileOptions {
+ sourceCompatibility(JavaVersion.VERSION_17)
+ targetCompatibility(JavaVersion.VERSION_17)
+ }
+}
+
+kotlin {
+ androidTarget {
+ compilations.all {
+ kotlinOptions {
+ jvmTarget = JavaVersion.VERSION_17.majorVersion
+ }
+ }
+ }
+}
+
dependencies {
commonMainImplementation(libs.coroutines)
diff --git a/sample/mpp-library/src/androidMain/AndroidManifest.xml b/sample/mpp-library/src/androidMain/AndroidManifest.xml
deleted file mode 100755
index 8f69414..0000000
--- a/sample/mpp-library/src/androidMain/AndroidManifest.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 35b9bd0..14e4f53 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -2,7 +2,6 @@
* Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/
-enableFeaturePreview("VERSION_CATALOGS")
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
dependencyResolutionManagement {