diff --git a/GoogleMapsXC.podspec b/GoogleMapsXC.podspec new file mode 100644 index 0000000..ca73044 --- /dev/null +++ b/GoogleMapsXC.podspec @@ -0,0 +1,24 @@ +Pod::Spec.new do |s| + s.name = 'GoogleMapsXC' + s.version = "6.1.1-beta" + s.summary = 'GoogleMaps with xcframework' + s.description = 'GoogleMaps with xcframework description' + s.homepage = 'https://github.com/icerockdev/moko-maps' + s.license = { :type => 'UNKNOWN' } + s.authors = 'Google' + s.source = { + :http => "https://dl.google.com/geosdk/GoogleMaps-#{s.version}-xcframework.tar.gz", + :type => "tgz" + } + + s.platform = :ios + s.ios.deployment_target = '12.0' + + s.frameworks = ["Accelerate", "CoreData", "CoreGraphics", "CoreImage", "CoreLocation", "CoreTelephony", "CoreText", "GLKit", "ImageIO" "Metal", "OpenGLES", "QuartzCore", "SystemConfiguration", "UIKit"] + s.libraries = ["c++", "z"] + s.vendored_frameworks = [ + "GoogleMaps.xcframework", + "GoogleMapsBase.xcframework", + "GoogleMapsCore.xcframework" + ] +end diff --git a/MapBoxWrapper.podspec b/MapBoxWrapper.podspec new file mode 100644 index 0000000..e27486f --- /dev/null +++ b/MapBoxWrapper.podspec @@ -0,0 +1,19 @@ +Pod::Spec.new do |s| + s.name = 'MapBoxWrapper' + s.version = "10.4.1" + s.summary = 'GoogleMaps with xcframework' + s.description = 'GoogleMaps with xcframework description' + s.homepage = 'https://github.com/icerockdev/moko-maps' + s.license = { :type => 'UNKNOWN' } + s.authors = 'Google' + s.source = { + :http => "none", + :type => "tgz" + } + + s.platform = :ios + s.ios.deployment_target = '12.0' + + s.dependency 'MapboxMaps', "#{s.version}" + s.source_files = 'maps-mapbox/src/iosMain/swift/*.swift' +end diff --git a/README.md b/README.md index 0b1aa90..fd726a2 100755 --- a/README.md +++ b/README.md @@ -38,9 +38,9 @@ allprojects { project build.gradle ```groovy dependencies { - commonMainApi("dev.icerock.moko:maps:0.6.0") - commonMainApi("dev.icerock.moko:maps-google:0.6.0") - commonMainApi("dev.icerock.moko:maps-mapbox:0.6.0") + commonMainApi("dev.icerock.moko:maps:0.7.0") + commonMainApi("dev.icerock.moko:maps-google:0.7.0") + commonMainApi("dev.icerock.moko:maps-mapbox:0.7.0") } kotlin.targets diff --git a/build.gradle.kts b/build.gradle.kts index b663b04..f7cacbb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,36 +1,32 @@ /* * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. */ -import org.gradle.api.internal.artifacts.DefaultModuleVersionSelector buildscript { repositories { mavenCentral() google() gradlePluginPortal() + mavenLocal() } + dependencies { - classpath(":maps-build-logic") - classpath("dev.icerock.moko:resources-generator:0.16.1") - classpath("org.jetbrains.kotlin:kotlin-serialization:1.5.20") + classpath(libs.kotlinGradlePlugin) + classpath(libs.androidGradlePlugin) + classpath(libs.googleServicesGradlePlugin) + classpath(libs.firebaseGradlePlugin) + classpath(libs.mokoGradlePlugin) + classpath(libs.mobileMultiplatformGradlePlugin) + classpath(libs.kotlinSerializationGradlePlugin) + classpath(libs.mokoResourcesGeneratorGradlePlugin) } } +apply(plugin = "dev.icerock.moko.gradle.publication.nexus") +val mokoVersion = libs.versions.mokoMapsVersion.get() allprojects { - plugins.withId("org.gradle.maven-publish") { - group = "dev.icerock.moko" - version = libs.versions.mokoMapsVersion.get() - } - configurations.configureEach { - resolutionStrategy { - val coroutines: MinimalExternalModuleDependency = rootProject.libs.coroutines.get() - val forcedCoroutines: ModuleVersionSelector = DefaultModuleVersionSelector.newSelector( - coroutines.module, - coroutines.versionConstraint.requiredVersion - ) - force(forcedCoroutines) - } - } + group = "dev.icerock.moko" + version = mokoVersion } tasks.register("clean", Delete::class).configure { diff --git a/gradle.properties b/gradle.properties index 6effeb7..5fab2e0 100755 --- a/gradle.properties +++ b/gradle.properties @@ -12,6 +12,17 @@ android.enableJetifier=true xcodeproj=./sample/ios-app +moko.android.targetSdk=31 +moko.android.compileSdk=31 +moko.android.minSdk=16 + +moko.publish.name=MOKO maps +moko.publish.description=description +moko.publish.repo.org=icerockdev +moko.publish.repo.name=moko-maps +moko.publish.license=Apache-2.0 +moko.publish.developers=alex009|Aleksey Mikhailov|Aleksey.Mikhailov@icerockdev.com + mobile.multiplatform.iosTargetWarning=false mobile.multiplatform.podsProject=sample/ios-app/Pods/Pods.xcodeproj kotlin.mpp.stability.nowarn=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 310b673..87fd702 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -kotlinVersion = "1.5.20" +kotlinVersion = "1.6.10" lifecycleVersion = "2.2.0" androidAppCompatVersion = "1.2.0" espressoCoreVersion = "3.2.0" @@ -13,16 +13,16 @@ mapboxNavigationVersion = "1.5.1" mapboxAnnotationVersion = "0.9.0" mapboxServicesVersion = "5.8.0" multidexVersion = "2.0.1" -kotlinxSerializationVersion = "1.2.1" -coroutinesVersion = "1.5.0-native-mt" -ktorClientVersion = "1.6.0" -mokoGraphicsVersion = "0.7.0" -mokoParcelizeVersion = "0.7.1" -mokoResourcesVersion = "0.16.1" -mokoMvvmVersion = "0.11.0" -mokoGeoVersion = "0.4.0" -mokoPermissionsVersion = "0.10.1" -mokoMapsVersion = "0.6.0" +kotlinxSerializationVersion = "1.3.2" +coroutinesVersion = "1.6.0-native-mt" +ktorClientVersion = "1.6.7" +mokoGraphicsVersion = "0.9.0" +mokoParcelizeVersion = "0.8.0" +mokoResourcesVersion = "0.18.0" +mokoMvvmVersion = "0.12.0" +mokoGeoVersion = "0.5.0" +mokoPermissionsVersion = "0.11.0" +mokoMapsVersion = "0.7.0" [libraries] appCompat = { module = "androidx.appcompat:appcompat", version.ref = "androidAppCompatVersion" } @@ -39,15 +39,29 @@ ktorClientOkHttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktorC kotlinSerialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationVersion" } coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutinesVersion" } ktorClient = { module = "io.ktor:ktor-client-core", version.ref = "ktorClientVersion" } + mokoResources = { module = "dev.icerock.moko:resources", version.ref = "mokoResourcesVersion" } mokoParcelize = { module = "dev.icerock.moko:parcelize", version.ref = "mokoParcelizeVersion" } mokoGraphics = { module = "dev.icerock.moko:graphics", version.ref = "mokoGraphicsVersion" } -mokoMvvm = { module = "dev.icerock.moko:mvvm", version.ref = "mokoMvvmVersion" } +mokoMvvmCore = { module = "dev.icerock.moko:mvvm-core", version.ref = "mokoMvvmVersion" } +mokoMvvmLiveData = { module = "dev.icerock.moko:mvvm-livedata", version.ref = "mokoMvvmVersion" } +mokoMvvmDataBinding = { module = "dev.icerock.moko:mvvm-databinding", version.ref = "mokoMvvmVersion" } mokoGeo = { module = "dev.icerock.moko:geo", version.ref = "mokoGeoVersion" } mokoPermissions = { module = "dev.icerock.moko:permissions", version.ref = "mokoPermissionsVersion" } mokoMaps = { module = "dev.icerock.moko:maps", version.ref = "mokoMapsVersion" } mokoMapsGoogle = { module = "dev.icerock.moko:maps-google", version.ref = "mokoMapsVersion" } mokoMapsMapbox = { module = "dev.icerock.moko:maps-mapbox", version.ref = "mokoMapsVersion" } + kotlinTest = { module = "org.jetbrains.kotlin:kotlin-test-common", version.ref = "kotlinVersion" } ktorClientIos = { module = "io.ktor:ktor-client-ios", version.ref = "ktorClientVersion" } + +kotlinGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlinVersion" } +androidGradlePlugin = { module = "com.android.tools.build:gradle", version = "7.0.4" } +googleServicesGradlePlugin = { module = "com.google.gms:google-services", version = "4.3.8" } +firebaseGradlePlugin = { module = "com.google.firebase:firebase-crashlytics-gradle", version = "2.2.0" } +mokoGradlePlugin = { module = "dev.icerock.moko:moko-gradle-plugin", version = "0.1.0" } +mobileMultiplatformGradlePlugin = { module = "dev.icerock:mobile-multiplatform", version = "0.15.0" } +mokoResourcesGeneratorGradlePlugin = { module = "dev.icerock.moko:resources-generator", version.ref = "mokoResourcesVersion" } +kotlinSerializationGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlinVersion" } + diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0f80bbf..00e33ed 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.0.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/maps-build-logic/build.gradle.kts b/maps-build-logic/build.gradle.kts deleted file mode 100644 index 84cbae3..0000000 --- a/maps-build-logic/build.gradle.kts +++ /dev/null @@ -1,17 +0,0 @@ -plugins { - `kotlin-dsl` -} - -repositories { - mavenCentral() - google() - - gradlePluginPortal() -} - -dependencies { - api("dev.icerock:mobile-multiplatform:0.12.0") - api("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20") - api("com.android.tools.build:gradle:4.2.1") - api("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.15.0") -} diff --git a/maps-build-logic/src/main/kotlin/android-app-convention.gradle.kts b/maps-build-logic/src/main/kotlin/android-app-convention.gradle.kts deleted file mode 100644 index 2859874..0000000 --- a/maps-build-logic/src/main/kotlin/android-app-convention.gradle.kts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. - */ - -plugins { - id("com.android.application") - id("android-base-convention") - id("kotlin-android") -} - -android { - dexOptions { - javaMaxHeapSize = "2g" - } - - buildTypes { - getByName("release") { - isMinifyEnabled = true - proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") - } - getByName("debug") { - isDebuggable = true - applicationIdSuffix = ".debug" - } - } - - packagingOptions { - exclude("META-INF/*.kotlin_module") - exclude("META-INF/AL2.0") - exclude("META-INF/LGPL2.1") - } -} diff --git a/maps-build-logic/src/main/kotlin/android-base-convention.gradle.kts b/maps-build-logic/src/main/kotlin/android-base-convention.gradle.kts deleted file mode 100644 index bfd44d3..0000000 --- a/maps-build-logic/src/main/kotlin/android-base-convention.gradle.kts +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. - */ - -import com.android.build.gradle.BaseExtension - -configure { - compileSdkVersion(30) - - defaultConfig { - minSdkVersion(21) - targetSdkVersion(30) - } -} diff --git a/maps-build-logic/src/main/kotlin/android-library-convention.gradle.kts b/maps-build-logic/src/main/kotlin/android-library-convention.gradle.kts deleted file mode 100644 index c435401..0000000 --- a/maps-build-logic/src/main/kotlin/android-library-convention.gradle.kts +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. - */ - -plugins { - id("com.android.library") - id("kotlin-android") - id("android-base-convention") -} - -android { - sourceSets.all { java.srcDir("src/$name/kotlin") } -} diff --git a/maps-build-logic/src/main/kotlin/android-publication-convention.gradle.kts b/maps-build-logic/src/main/kotlin/android-publication-convention.gradle.kts deleted file mode 100644 index b4dae9e..0000000 --- a/maps-build-logic/src/main/kotlin/android-publication-convention.gradle.kts +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. - */ - -plugins { - id("publication-convention") -} - -afterEvaluate { - publishing.publications { - create("release", MavenPublication::class.java) { - from(components.getByName("release")) - } - } -} diff --git a/maps-build-logic/src/main/kotlin/detekt-convention.gradle.kts b/maps-build-logic/src/main/kotlin/detekt-convention.gradle.kts deleted file mode 100644 index 68343a8..0000000 --- a/maps-build-logic/src/main/kotlin/detekt-convention.gradle.kts +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. - */ - -plugins { - id("io.gitlab.arturbosch.detekt") -} - -detekt { - input.setFrom("src/commonMain/kotlin", "src/androidMain/kotlin", "src/iosMain/kotlin", "src/main/kotlin") -} - -dependencies { - "detektPlugins"("io.gitlab.arturbosch.detekt:detekt-formatting:1.15.0") -} diff --git a/maps-build-logic/src/main/kotlin/javadoc-stub-convention.gradle.kts b/maps-build-logic/src/main/kotlin/javadoc-stub-convention.gradle.kts deleted file mode 100644 index a1a2691..0000000 --- a/maps-build-logic/src/main/kotlin/javadoc-stub-convention.gradle.kts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. - */ - -plugins { - id("org.gradle.maven-publish") -} - -val javadocJar by tasks.registering(Jar::class) { - archiveClassifier.set("javadoc") -} - -publishing.publications.withType { - // Stub javadoc.jar artifact - artifact(javadocJar.get()) -} diff --git a/maps-build-logic/src/main/kotlin/multiplatform-library-convention.gradle.kts b/maps-build-logic/src/main/kotlin/multiplatform-library-convention.gradle.kts deleted file mode 100644 index 347106b..0000000 --- a/maps-build-logic/src/main/kotlin/multiplatform-library-convention.gradle.kts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. - */ - -plugins { - id("com.android.library") - id("org.jetbrains.kotlin.multiplatform") - id("android-base-convention") - id("dev.icerock.mobile.multiplatform.android-manifest") -} - -kotlin { - ios() - android { - publishLibraryVariants("release", "debug") - } -} - diff --git a/maps-build-logic/src/main/kotlin/publication-convention.gradle.kts b/maps-build-logic/src/main/kotlin/publication-convention.gradle.kts deleted file mode 100644 index 46eeeca..0000000 --- a/maps-build-logic/src/main/kotlin/publication-convention.gradle.kts +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. - */ - -import java.util.Base64 - -plugins { - id("javadoc-stub-convention") - id("org.gradle.maven-publish") - id("signing") -} - -publishing { - repositories.maven("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") { - name = "OSSRH" - - credentials { - username = System.getenv("OSSRH_USER") - password = System.getenv("OSSRH_KEY") - } - } - - publications.withType { - // Provide artifacts information requited by Maven Central - pom { - name.set("MOKO maps") - description.set("Control your map from common code for mobile (android & ios) Kotlin Multiplatform development") - url.set("https://github.com/icerockdev/moko-maps") - licenses { - license { - name.set("Apache-2.0") - distribution.set("repo") - url.set("https://github.com/icerockdev/moko-maps/blob/master/LICENSE.md") - } - } - - developers { - developer { - id.set("Alex009") - name.set("Aleksey Mikhailov") - email.set("aleksey.mikhailov@icerockdev.com") - } - developer { - id.set("prokopishin") - name.set("Nikita Prokopishin") - email.set("nprokopishin@icerockdev.com") - } - developer { - id.set("Dorofeev") - name.set("Andrey Dorofeev") - email.set("adorofeev@icerockdev.com") - } - } - - scm { - connection.set("scm:git:ssh://github.com/icerockdev/moko-maps.git") - developerConnection.set("scm:git:ssh://github.com/icerockdev/moko-maps.git") - url.set("https://github.com/icerockdev/moko-maps") - } - } - } -} - - -signing { - val signingKeyId: String? = System.getenv("SIGNING_KEY_ID") - val signingPassword: String? = System.getenv("SIGNING_PASSWORD") - val signingKey: String? = System.getenv("SIGNING_KEY")?.let { base64Key -> - String(Base64.getDecoder().decode(base64Key)) - } - if (signingKeyId != null) { - useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) - sign(publishing.publications) - } -} diff --git a/maps-google/build.gradle.kts b/maps-google/build.gradle.kts index 20583c1..cf98007 100644 --- a/maps-google/build.gradle.kts +++ b/maps-google/build.gradle.kts @@ -3,9 +3,10 @@ */ plugins { - id("multiplatform-library-convention") - id("dev.icerock.mobile.multiplatform.android-manifest") - id("publication-convention") + id("dev.icerock.moko.gradle.multiplatform.mobile") + id("dev.icerock.moko.gradle.publication") + id("dev.icerock.moko.gradle.stub.javadoc") + id("dev.icerock.moko.gradle.detekt") id("kotlin-parcelize") id("kotlin-kapt") id("kotlinx-serialization") @@ -21,14 +22,14 @@ dependencies { commonMainApi(libs.mokoGeo) commonMainApi(libs.mokoGraphics) - "androidMainImplementation"(libs.appCompat) - "androidMainImplementation"(libs.lifecycle) - "androidMainApi"(libs.playServicesLocation) - "androidMainApi"(libs.playServicesMaps) - "androidMainImplementation"(libs.googleMapsServices) - "androidMainImplementation"(libs.ktorClientOkHttp) + androidMainImplementation(libs.appCompat) + androidMainImplementation(libs.lifecycle) + androidMainApi(libs.playServicesLocation) + androidMainApi(libs.playServicesMaps) + androidMainImplementation(libs.googleMapsServices) - "iosMainImplementation"(libs.ktorClientIos) + androidMainImplementation(libs.ktorClientOkHttp) + iosMainImplementation(libs.ktorClientIos) } cocoaPods { @@ -38,12 +39,19 @@ cocoaPods { extraLinkerOpts = listOf( "GoogleMapsBase", "GoogleMapsCore", "CoreGraphics", "QuartzCore", "UIKit", "ImageIO", "OpenGLES", "CoreData", "CoreText", "SystemConfiguration", "Security", - "CoreTelephony", "CoreImage" + "CoreTelephony", "CoreImage", "Metal" ).map { "-framework $it" } - ) { podsDir -> + ) { podsDir, target -> + val sdkPath = when (target.konanTarget) { + is org.jetbrains.kotlin.konan.target.KonanTarget.IOS_SIMULATOR_ARM64, + is org.jetbrains.kotlin.konan.target.KonanTarget.IOS_X64 -> "ios-x86_64_arm64-simulator" + is org.jetbrains.kotlin.konan.target.KonanTarget.IOS_ARM64 -> "ios-arm64" + else -> throw IllegalArgumentException("invalid target $target") + } listOf( - File(podsDir, "GoogleMaps/Base/Frameworks"), - File(podsDir, "GoogleMaps/Maps/Frameworks") - ) + "GoogleMapsBase", + "GoogleMapsCore", + "GoogleMaps" + ).map { File(podsDir, "GoogleMapsXC/$it.xcframework/$sdkPath") } } } diff --git a/maps-google/src/iosSimulatorArm64Main b/maps-google/src/iosSimulatorArm64Main new file mode 120000 index 0000000..46be4b8 --- /dev/null +++ b/maps-google/src/iosSimulatorArm64Main @@ -0,0 +1 @@ +iosX64Main \ No newline at end of file diff --git a/maps-google/src/iosX64Main/kotlin/dev/icerock/moko/maps/google/GoogleMapController.kt b/maps-google/src/iosX64Main/kotlin/dev/icerock/moko/maps/google/GoogleMapController.kt index c0310a5..ba98be3 100644 --- a/maps-google/src/iosX64Main/kotlin/dev/icerock/moko/maps/google/GoogleMapController.kt +++ b/maps-google/src/iosX64Main/kotlin/dev/icerock/moko/maps/google/GoogleMapController.kt @@ -224,6 +224,7 @@ actual class GoogleMapController( takeFrom("https://maps.googleapis.com/maps/api/directions/json?$originStr&$destinationStr&$key$waypoints") } + @Suppress("SwallowedException") try { val result: String = httpClient.request(builder) return buildRoute(result, lineColor, markersImage) diff --git a/maps-mapbox/build.gradle.kts b/maps-mapbox/build.gradle.kts index 92242b6..79f4ae3 100644 --- a/maps-mapbox/build.gradle.kts +++ b/maps-mapbox/build.gradle.kts @@ -3,9 +3,10 @@ */ plugins { - id("multiplatform-library-convention") - id("dev.icerock.mobile.multiplatform.android-manifest") - id("publication-convention") + id("dev.icerock.moko.gradle.multiplatform.mobile") + id("dev.icerock.moko.gradle.publication") + id("dev.icerock.moko.gradle.stub.javadoc") + id("dev.icerock.moko.gradle.detekt") id("kotlin-parcelize") id("dev.icerock.mobile.multiplatform.cocoapods") } @@ -15,19 +16,27 @@ dependencies { commonMainApi(projects.maps) - "androidMainImplementation"(libs.appCompat) - "androidMainImplementation"(libs.lifecycle) - "androidMainImplementation"(libs.playServicesLocation) - "androidMainImplementation"(libs.mapboxAnnotation) - "androidMainImplementation"(libs.mapboxServices) - "androidMainApi"(libs.mapbox) - "androidMainApi"(libs.mapboxNavigation) + androidMainImplementation(libs.appCompat) + androidMainImplementation(libs.lifecycle) + androidMainImplementation(libs.playServicesLocation) + androidMainImplementation(libs.mapboxAnnotation) + androidMainImplementation(libs.mapboxServices) + androidMainApi(libs.mapbox) + androidMainApi(libs.mapboxNavigation) } cocoaPods { precompiledPod( - scheme = "Mapbox" - ) { podsDir -> - listOf(File(podsDir, "Mapbox-iOS-SDK/dynamic")) + scheme = "MapboxCoreMaps" + ) { podsDir, target -> + val sdkPath = when (target.konanTarget) { + is org.jetbrains.kotlin.konan.target.KonanTarget.IOS_SIMULATOR_ARM64, + is org.jetbrains.kotlin.konan.target.KonanTarget.IOS_X64 -> "ios-arm64_x86_64-simulator" + is org.jetbrains.kotlin.konan.target.KonanTarget.IOS_ARM64 -> "ios-arm64" + else -> throw IllegalArgumentException("invalid target $target") + } + listOf( + "MapboxCoreMaps" + ).map { File(podsDir, "$it/$it.xcframework/$sdkPath") } } } diff --git a/maps-mapbox/src/androidMain/kotlin/dev/icerock/moko/maps/mapbox/MapboxController.kt b/maps-mapbox/src/androidMain/kotlin/dev/icerock/moko/maps/mapbox/MapboxController.kt index 8783cb2..003725a 100644 --- a/maps-mapbox/src/androidMain/kotlin/dev/icerock/moko/maps/mapbox/MapboxController.kt +++ b/maps-mapbox/src/androidMain/kotlin/dev/icerock/moko/maps/mapbox/MapboxController.kt @@ -242,6 +242,7 @@ actual class MapboxController( fillOpacity(backgroundOpacity) ) + @Suppress("ArrayPrimitive") val lineLayer: LineLayer = LineLayer(lineLayerId, sourceId) .withProperties( lineWidth(lineWidth), @@ -287,7 +288,7 @@ actual class MapboxController( .accessToken(accessToken) .build() - @Suppress("BlockingMethodInNonBlockingContext") + @Suppress("BlockingMethodInNonBlockingContext", "UnsafeCallOnNullableType") val directionsRoute = withContext(Dispatchers.Default) { val result = directionsClient.executeCall() if (!result.isSuccessful) { @@ -362,6 +363,7 @@ actual class MapboxController( } } + @Suppress("ReturnCount") override suspend fun getSimilarNearAddresses( text: String?, maxResults: Int, @@ -373,14 +375,15 @@ actual class MapboxController( val locationProviderClient = locationHolder.get() val lastLocation: Location = suspendCoroutine { continuation -> + @Suppress("UnsafeCallOnNullableType") locationProviderClient.lastLocation.addOnCompleteListener { if (it.isSuccessful) { - continuation.resume(it.result!!) + continuation.resume(it.result) } else { continuation.resumeWithException(it.exception!!) } } - } + } ?: return emptyList() // TODO calculate bounds from radius @Suppress("MagicNumber") diff --git a/maps-mapbox/src/androidMain/kotlin/dev/icerock/moko/maps/mapbox/MapboxMarker.kt b/maps-mapbox/src/androidMain/kotlin/dev/icerock/moko/maps/mapbox/MapboxMarker.kt index 52d25c5..4689fef 100644 --- a/maps-mapbox/src/androidMain/kotlin/dev/icerock/moko/maps/mapbox/MapboxMarker.kt +++ b/maps-mapbox/src/androidMain/kotlin/dev/icerock/moko/maps/mapbox/MapboxMarker.kt @@ -31,7 +31,7 @@ actual class MapboxMarker( removeHandler.invoke(symbol) } - @ExperimentalTime + @OptIn(ExperimentalTime::class) override fun move(position: LatLng, rotation: Float, duration: Duration) { val currentPosition = symbol.latLng val newPosition = position.toMapboxLatLng() diff --git a/maps-mapbox/src/iosMain/swift/MapBoxWrapper.swift b/maps-mapbox/src/iosMain/swift/MapBoxWrapper.swift new file mode 100644 index 0000000..e006b0d --- /dev/null +++ b/maps-mapbox/src/iosMain/swift/MapBoxWrapper.swift @@ -0,0 +1,376 @@ +/* + * Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +import Foundation +import MapboxMaps +import CoreLocation +import MapKit + + +//class MapboxAnnotation : MGLPointAnnotation() { +// var onClick: (() -> Unit)? = null +// var image: UIImage? = null +//} + +//actual class MapboxMarker( +// private val annotation: MGLPointAnnotation, +// private val onDeleteCallback: (() -> Unit)? +//) : Marker { +// +// var onClick: (() -> Unit)? = null +// var image: UIImage? = null +// +// override fun delete() { +// onDeleteCallback?.invoke() +// } +// +// override var position: LatLng +// get() = annotation.coordinate.toLatLng() +// set(value) { +// annotation.setCoordinate(coordinate = value.toCoord2D()) +// } +// +// override var rotation: Float +// get() = TODO("rotation not work for markers of Mapbox") +// set(_) { TODO("rotation not work for markers of Mapbox") } +// +// @OptIn(ExperimentalTime::class) +// override fun move(position: LatLng, rotation: Float, duration: Duration) { +// CATransaction.begin() +// CATransaction.setAnimationDuration(duration.inSeconds) +// +// annotation.setCoordinate(coordinate = position.toCoord2D()) +// +// CATransaction.commit() +// } +// +// fun getAnnotation(): MGLPointAnnotation { +// return annotation +// } +//} + +@objc +public class MapboxSettingsNative: NSObject { + public var compassEnabled: Bool = false + public var myLocationEnabled: Bool = false + public var scrollGesturesEnabled: Bool = false + public var zoomGesturesEnabled: Bool = false + public var tiltGesturesEnabled: Bool = false + public var rotateGesturesEnabled: Bool = false + public var logoIsVisible: Bool = false + public var infoButtonIsVisible: Bool = false +} + +@objc +public class MapboxControllerNative: NSObject { + private let mapView: MapView + private let locationManager = CLLocationManager() + + init(mapView: MapView) { + self.mapView = mapView + } + + public func getSettings() -> MapboxSettingsNative { + let settings = MapboxSettingsNative() + + settings.compassEnabled = mapView.ornaments.options.compass.visibility != .hidden + settings.myLocationEnabled = false // mapView?.showsUserLocation ?: false, + settings.scrollGesturesEnabled = false // mapView?.scrollEnabled ?: false, + settings.zoomGesturesEnabled = false // mapView?.zoomEnabled ?: false, + settings.tiltGesturesEnabled = false // mapView?.pitchEnabled ?: false, + settings.rotateGesturesEnabled = false // mapView?.rotateEnabled ?: false, + settings.logoIsVisible = !mapView.ornaments.logoView.isHidden + settings.infoButtonIsVisible = !mapView.ornaments.attributionButton.isHidden + + return settings + } + + public func setSettings(_ settings: MapboxSettingsNative) { + if settings.compassEnabled { + mapView.ornaments.options.compass.visibility = .adaptive + } else { + mapView.ornaments.options.compass.visibility = .hidden + } + + // it.showsUserLocation = settings.myLocationEnabled + // it.scrollEnabled = settings.scrollGesturesEnabled + // it.rotateEnabled = settings.rotateGesturesEnabled + // it.zoomEnabled = settings.zoomGesturesEnabled + // it.pitchEnabled = settings.tiltGesturesEnabled + + mapView.ornaments.logoView.isHidden = !settings.logoIsVisible + mapView.ornaments.attributionButton.isHidden = !settings.infoButtonIsVisible + } +} + +//actual class MapboxController( +// mapView: MGLMapView +//) : MapController { +// +// private val locationManager = CLLocationManager() +// private val delegate = MapDelegate(this) +// +// private val weakMapView = WeakReference(mapView) +// +// private var isMapLoaded: Boolean = false +// +// private val markers: MutableMap = mutableMapOf() +// +// actual var onStartScrollCallback: ((isUserGesture: Boolean) -> Unit)? = null +// +// init { +// weakMapView.get()?.delegate = delegate +// } +// +// private fun getCurrentLocation(): LatLng { +// val location: CLLocation = weakMapView.get()?.userLocation?.location +// ?: locationManager.location +// ?: throw IllegalStateException("can't get location") +// +// return location.coordinate.toLatLng() +// } + +// override suspend fun getCurrentZoom(): Float { +// return weakMapView.get()?.zoomLevel?.toFloat() ?: 0f +// } +// +// override suspend fun setCurrentZoom(zoom: Float) { +// weakMapView.get()?.zoomLevel = zoom.toDouble() +// } +// +// override suspend fun getZoomConfig(): ZoomConfig { +// return ZoomConfig( +// min = weakMapView.get()?.minimumZoomLevel?.toFloat(), +// max = weakMapView.get()?.maximumZoomLevel?.toFloat() +// ) +// } +// +// override suspend fun setZoomConfig(config: ZoomConfig) { +// weakMapView.get()?.minimumZoomLevel = config.min?.toDouble() ?: DEFAULT_MINIMUM_ZOOM +// weakMapView.get()?.maximumZoomLevel = config.max?.toDouble() ?: DEFAULT_MAXIMUM_ZOOM +// } +// +// override suspend fun getMapCenterLatLng(): LatLng { +// return weakMapView.get()?.camera?.centerCoordinate?.toLatLng() ?: LatLng( +// latitude = 0.0, +// longitude = 0.0 +// ) +// } +// +// override fun showLocation(latLng: LatLng, zoom: Float, animation: Boolean) { +// weakMapView.get()?.setCenterCoordinate( +// centerCoordinate = latLng.toCoord2D(), +// zoomLevel = zoom.toDouble(), +// animated = if (isMapLoaded) { +// animation +// } else { +// false +// } +// ) +// } +// +// override fun showMyLocation(zoom: Float) { +// val location = getCurrentLocation() +// showLocation(latLng = location, zoom = zoom, animation = true) +// } +// +// override suspend fun addMarker( +// image: ImageResource, +// latLng: LatLng, +// rotation: Float, +// onClick: (() -> Unit)? +// ): Marker { +// val annotation = MGLPointAnnotation() +// annotation.setCoordinate(coordinate = latLng.toCoord2D()) +// +// // TODO: Need implementation for rotation +// if (rotation != 0.0f) println("WARNING: rotation not work for markers of Mapbox") +// +// val marker = MapboxMarker( +// annotation = annotation, +// onDeleteCallback = { +// weakMapView.get()?.removeAnnotation(annotation = annotation) +// markers.remove(annotation) +// } +// ) +// +// marker.onClick = onClick +// marker.image = image.toUIImage() +// markers.put(annotation, marker) +// +// weakMapView.get()?.addAnnotation(annotation) +// +// return marker +// } +// +// actual fun setStyleUrl(styleUrl: String) { +// weakMapView.get()?.styleURL = NSURL(string = styleUrl) +// } +// +// override suspend fun drawPolygon( +// pointList: List, +// backgroundColor: Color, +// lineColor: Color, +// backgroundOpacity: Float, +// lineWidth: Float, +// lineOpacity: Float, +// lineType: LineType +// ): MapElement { +// val polygon: MGLPolygonFeature = memScoped { +// +// val items = createValues(pointList.count()) { pos -> +// this.longitude = pointList[pos].longitude +// this.latitude = pointList[pos].latitude +// } +// MGLPolygonFeature.polygonWithCoordinates( +// coords = items.ptr, +// count = pointList.count().toULong() +// ) +// } +// val settings = MapboxPolygonSettings( +// fillColor = backgroundColor.toUIColor() +// .colorWithAlphaComponent(backgroundOpacity.toDouble()), +// lineColor = lineColor.toUIColor().colorWithAlphaComponent(lineOpacity.toDouble()) +// ) +// delegate.polygonSettings[polygon.hashCode()] = settings +// +// val source = MGLShapeSource( +// identifier = "line:${(0..Int.MAX_VALUE).random()}", +// shape = polygon, +// options = null +// ) +// delegate.style?.addSource(source) +// +// val layer = MGLLineStyleLayer( +// identifier = "line-layer:${(0..Int.MAX_VALUE).random()}", +// source = source +// ) +// if (lineType == LineType.DASHED) { +// layer.lineDashPattern = +// NSExpression.expressionForConstantValue(List(2) { 2.0 }) +// } +// layer.lineWidth = NSExpression.expressionForConstantValue(lineWidth) +// layer.lineColor = NSExpression.expressionForConstantValue( +// lineColor.toUIColor().colorWithAlphaComponent(lineOpacity.toDouble()) +// ) +// delegate.style?.addLayer(layer) +// +// weakMapView.get()?.addOverlay(polygon) +// return MapboxPolygon { +// weakMapView.get()?.removeOverlay(polygon) +// delegate.style?.removeLayer(layer) +// } +// } +// +// override suspend fun buildRoute( +// points: List, +// lineColor: Color, +// markersImage: ImageResource? +// ): MapElement { +// TODO("for now MapboxDirections pod can't be cinteroped, so on iOS this not implemented") +// } +// +// override suspend fun getAddressByLatLng(latitude: Double, longitude: Double): String? { +// TODO("for now MapboxDirections pod can't be cinteroped, so on iOS this not implemented") +// } +// +// override suspend fun getSimilarNearAddresses( +// text: String?, +// maxResults: Int, +// maxRadius: Int +// ): List { +// TODO("for now MapboxDirections pod can't be cinteroped, so on iOS this not implemented") +// } +// +// @Suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE", "CONFLICTING_OVERLOADS") +// private class MapDelegate( +// mapController: MapboxController +// ) : NSObject(), MGLMapViewDelegateProtocol { +// private val mapController = WeakReference(mapController) +// +// var polygonSettings: MutableMap = mutableMapOf() +// +// var style: MGLStyle? = null +// +// override fun mapViewDidFinishLoadingMap(mapView: MGLMapView) { +// mapController.get()?.isMapLoaded = true +// } +// +// override fun mapView(mapView: MGLMapView, didFinishLoadingStyle: MGLStyle) { +// style = didFinishLoadingStyle +// } +// +// override fun mapView( +// mapView: MGLMapView, +// regionWillChangeWithReason: MGLCameraChangeReason, +// animated: Boolean +// ) { +// when (regionWillChangeWithReason) { +// MGLCameraChangeReasonGesturePan, +// MGLCameraChangeReasonGestureZoomIn, +// MGLCameraChangeReasonGestureZoomOut, +// MGLCameraChangeReasonGesturePinch -> mapController.get()?.onStartScrollCallback?.invoke( +// true +// ) +// else -> mapController.get()?.onStartScrollCallback?.invoke(false) +// } +// } +// +// @Suppress("RETURN_TYPE_MISMATCH_ON_OVERRIDE") +// override fun mapView( +// mapView: MGLMapView, +// imageForAnnotation: MGLAnnotationProtocol +// ): MGLAnnotationImage? { +// val annotation = imageForAnnotation as MGLPointAnnotation +// val image = mapController.value?.markers?.get(annotation)?.image +// return if (image != null) { +// MGLAnnotationImage.annotationImageWithImage( +// image = image, +// reuseIdentifier = image.toString() +// ) +// } else { +// null +// } +// } +// +// // it also called for polygons (may be useful in feature) +// @Suppress("RETURN_TYPE_MISMATCH_ON_OVERRIDE") +// override fun mapView(mapView: MGLMapView, didSelectAnnotation: MGLAnnotationProtocol) { +// val annotation = (didSelectAnnotation as? MGLPointAnnotation) +// annotation?.let { mapController.value?.markers?.get(it)?.onClick?.invoke() } +// } +// +// override fun mapView( +// mapView: MGLMapView, +// fillColorForPolygonAnnotation: MGLPolygon +// ): UIColor { +// @Suppress("SwallowedException") +// return try { +// val settings = polygonSettings.getValue(fillColorForPolygonAnnotation.hashCode()) +// settings.fillColor +// } catch (exception: NoSuchElementException) { +// UIColor.blueColor() +// } +// } +// +// @Suppress("RETURN_TYPE_MISMATCH_ON_OVERRIDE") +// override fun mapView( +// mapView: MGLMapView, +// strokeColorForShapeAnnotation: MGLShape +// ): UIColor { +// @Suppress("SwallowedException") +// return try { +// val settings = polygonSettings.getValue(strokeColorForShapeAnnotation.hashCode()) +// settings.lineColor +// } catch (exception: NoSuchElementException) { +// UIColor.blueColor() +// } +// } +// } +// +// private companion object { +// const val DEFAULT_MINIMUM_ZOOM: Double = 0.0 +// const val DEFAULT_MAXIMUM_ZOOM: Double = 22.0 +// } +//} diff --git a/maps-mapbox/src/iosSimulatorArm64Main b/maps-mapbox/src/iosSimulatorArm64Main new file mode 120000 index 0000000..46be4b8 --- /dev/null +++ b/maps-mapbox/src/iosSimulatorArm64Main @@ -0,0 +1 @@ +iosX64Main \ No newline at end of file diff --git a/maps-mapbox/src/iosX64Main/kotlin/dev/icerock/moko/maps/mapbox/MapboxController.kt b/maps-mapbox/src/iosX64Main/kotlin/dev/icerock/moko/maps/mapbox/MapboxController.kt index 94ba0e9..51247f5 100644 --- a/maps-mapbox/src/iosX64Main/kotlin/dev/icerock/moko/maps/mapbox/MapboxController.kt +++ b/maps-mapbox/src/iosX64Main/kotlin/dev/icerock/moko/maps/mapbox/MapboxController.kt @@ -73,9 +73,9 @@ actual class MapboxController( actual suspend fun readUiSettings(): UiSettings { val mapView = weakMapView.get() + val compass = mapView?.compassView?.compassVisibility return UiSettings( - compassEnabled = mapView?.compassView?.compassVisibility != - MGLOrnamentVisibility.MGLOrnamentVisibilityHidden, + compassEnabled = compass != MGLOrnamentVisibility.MGLOrnamentVisibilityHidden, myLocationEnabled = mapView?.showsUserLocation ?: false, scrollGesturesEnabled = mapView?.scrollEnabled ?: false, zoomGesturesEnabled = mapView?.zoomEnabled ?: false, @@ -317,6 +317,7 @@ actual class MapboxController( mapView: MGLMapView, fillColorForPolygonAnnotation: MGLPolygon ): UIColor { + @Suppress("SwallowedException") return try { val settings = polygonSettings.getValue(fillColorForPolygonAnnotation.hashCode()) settings.fillColor @@ -330,6 +331,7 @@ actual class MapboxController( mapView: MGLMapView, strokeColorForShapeAnnotation: MGLShape ): UIColor { + @Suppress("SwallowedException") return try { val settings = polygonSettings.getValue(strokeColorForShapeAnnotation.hashCode()) settings.lineColor diff --git a/maps-mapbox/src/iosX64Main/kotlin/dev/icerock/moko/maps/mapbox/MapboxMarker.kt b/maps-mapbox/src/iosX64Main/kotlin/dev/icerock/moko/maps/mapbox/MapboxMarker.kt index da0372a..15f18a2 100644 --- a/maps-mapbox/src/iosX64Main/kotlin/dev/icerock/moko/maps/mapbox/MapboxMarker.kt +++ b/maps-mapbox/src/iosX64Main/kotlin/dev/icerock/moko/maps/mapbox/MapboxMarker.kt @@ -33,9 +33,9 @@ actual class MapboxMarker( override var rotation: Float get() = TODO("rotation not work for markers of Mapbox") - set(value) { TODO("rotation not work for markers of Mapbox") } + set(_) { TODO("rotation not work for markers of Mapbox") } - @ExperimentalTime + @OptIn(ExperimentalTime::class) override fun move(position: LatLng, rotation: Float, duration: Duration) { CATransaction.begin() CATransaction.setAnimationDuration(duration.inSeconds) diff --git a/maps/build.gradle.kts b/maps/build.gradle.kts index 3e12ebf..62a9bed 100644 --- a/maps/build.gradle.kts +++ b/maps/build.gradle.kts @@ -3,9 +3,10 @@ */ plugins { - id("multiplatform-library-convention") - id("dev.icerock.mobile.multiplatform.android-manifest") - id("publication-convention") + id("dev.icerock.moko.gradle.multiplatform.mobile") + id("dev.icerock.moko.gradle.publication") + id("dev.icerock.moko.gradle.stub.javadoc") + id("dev.icerock.moko.gradle.detekt") id("kotlin-kapt") id("kotlin-parcelize") } diff --git a/maps/src/commonMain/kotlin/dev/icerock/moko/maps/Marker.kt b/maps/src/commonMain/kotlin/dev/icerock/moko/maps/Marker.kt index 96beea7..c3620b9 100644 --- a/maps/src/commonMain/kotlin/dev/icerock/moko/maps/Marker.kt +++ b/maps/src/commonMain/kotlin/dev/icerock/moko/maps/Marker.kt @@ -6,12 +6,10 @@ package dev.icerock.moko.maps import dev.icerock.moko.geo.LatLng import kotlin.time.Duration -import kotlin.time.ExperimentalTime interface Marker : MapElement { var position: LatLng var rotation: Float - @OptIn(ExperimentalTime::class) fun move(position: LatLng, rotation: Float = 0.0f, duration: Duration) } diff --git a/sample/android-app/build.gradle.kts b/sample/android-app/build.gradle.kts index 4241244..a2c02f4 100644 --- a/sample/android-app/build.gradle.kts +++ b/sample/android-app/build.gradle.kts @@ -1,6 +1,6 @@ plugins { - id("android-app-convention") - id("kotlin-android") + id("dev.icerock.moko.gradle.android.application") + id("dev.icerock.moko.gradle.detekt") id("kotlin-kapt") } @@ -8,6 +8,8 @@ android { buildFeatures.dataBinding = true defaultConfig { + minSdk = 21 + applicationId = "dev.icerock.moko.samples.maps" versionCode = 1 @@ -34,4 +36,5 @@ dependencies { implementation(libs.multidex) implementation(projects.sample.mppLibrary) + implementation(libs.mokoMvvmDataBinding) } diff --git a/sample/android-app/src/main/AndroidManifest.xml b/sample/android-app/src/main/AndroidManifest.xml index ee7681f..7e3ea69 100755 --- a/sample/android-app/src/main/AndroidManifest.xml +++ b/sample/android-app/src/main/AndroidManifest.xml @@ -9,10 +9,10 @@ - + diff --git a/sample/android-app/src/main/java/com/icerockdev/app/GoogleMapsActivity.kt b/sample/android-app/src/main/java/com/icerockdev/app/GoogleMapsActivity.kt index 0250d8c..a3e1e5d 100644 --- a/sample/android-app/src/main/java/com/icerockdev/app/GoogleMapsActivity.kt +++ b/sample/android-app/src/main/java/com/icerockdev/app/GoogleMapsActivity.kt @@ -9,7 +9,6 @@ import androidx.lifecycle.ViewModelProvider import com.google.android.gms.maps.SupportMapFragment import com.icerockdev.app.databinding.ActivityGoogleMapsBinding import com.icerockdev.library.GoogleMapViewModel -import dev.icerock.moko.geo.LocationTracker import dev.icerock.moko.maps.google.GoogleMapController import dev.icerock.moko.mvvm.MvvmActivity import dev.icerock.moko.mvvm.createViewModelFactory diff --git a/sample/android-app/src/main/java/com/icerockdev/app/MainActivity.kt b/sample/android-app/src/main/java/com/icerockdev/app/MainActivity.kt index 0fe5a01..440f142 100644 --- a/sample/android-app/src/main/java/com/icerockdev/app/MainActivity.kt +++ b/sample/android-app/src/main/java/com/icerockdev/app/MainActivity.kt @@ -26,4 +26,4 @@ class MainActivity : AppCompatActivity() { startActivity(Intent(this, MapboxActivity::class.java)) } } -} \ No newline at end of file +} diff --git a/sample/android-app/src/main/java/com/icerockdev/app/MapboxActivity.kt b/sample/android-app/src/main/java/com/icerockdev/app/MapboxActivity.kt index 2792e0a..e67c249 100644 --- a/sample/android-app/src/main/java/com/icerockdev/app/MapboxActivity.kt +++ b/sample/android-app/src/main/java/com/icerockdev/app/MapboxActivity.kt @@ -15,7 +15,6 @@ import dev.icerock.moko.mvvm.MvvmActivity import dev.icerock.moko.mvvm.createViewModelFactory import dev.icerock.moko.permissions.PermissionsController - class MapboxActivity : MvvmActivity() { override val layoutId: Int = R.layout.activity_mapbox override val viewModelVariableId: Int = BR.viewModel diff --git a/sample/ios-app/Podfile b/sample/ios-app/Podfile index 48da49c..d9e8e4c 100644 --- a/sample/ios-app/Podfile +++ b/sample/ios-app/Podfile @@ -7,30 +7,29 @@ install! 'cocoapods', :disable_input_output_paths => true inhibit_all_warnings! use_frameworks! -platform :ios, '11.0' +platform :ios, '12.0' target 'TestProj' do # MultiPlatformLibrary pod 'MultiPlatformLibrary', :path => '../mpp-library' - pod 'Mapbox-iOS-SDK', '6.3.0' - pod 'MapboxNavigation', '1.4.1' - pod 'GoogleMaps', '5.1.0' + pod 'GoogleMapsXC', :podspec => '../../GoogleMapsXC.podspec' + pod 'MapBoxWrapper', :path => '../..' end # GoogleMaps is static library that already linked in moko-maps-google. Remove duplicated linking. -post_install do |installer| - host_targets = installer.aggregate_targets.select { |aggregate_target| - aggregate_target.name.include? "Pods-" - } - - host_targets.each do |host_target| - host_target.xcconfigs.each do |config_name, config_file| - config_file.frameworks.delete("GoogleMaps") - config_file.frameworks.delete("GoogleMapsBase") - config_file.frameworks.delete("GoogleMapsCore") - - xcconfig_path = host_target.xcconfig_path(config_name) - config_file.save_as(xcconfig_path) - end - end -end \ No newline at end of file +# post_install do |installer| +# host_targets = installer.aggregate_targets.select { |aggregate_target| +# aggregate_target.name.include? "Pods-" +# } +# +# host_targets.each do |host_target| +# host_target.xcconfigs.each do |config_name, config_file| +# config_file.frameworks.delete("GoogleMaps") +# config_file.frameworks.delete("GoogleMapsBase") +# config_file.frameworks.delete("GoogleMapsCore") +# +# xcconfig_path = host_target.xcconfig_path(config_name) +# config_file.save_as(xcconfig_path) +# end +# end +# end \ No newline at end of file diff --git a/sample/ios-app/Podfile.lock b/sample/ios-app/Podfile.lock index 5055cbb..58eb776 100644 --- a/sample/ios-app/Podfile.lock +++ b/sample/ios-app/Podfile.lock @@ -1,75 +1,50 @@ PODS: - - GoogleMaps (3.7.0): - - GoogleMaps/Maps (= 3.7.0) - - GoogleMaps/Base (3.7.0) - - GoogleMaps/Maps (3.7.0): - - GoogleMaps/Base - - Mapbox-iOS-SDK (5.6.0): - - MapboxMobileEvents (= 0.10.2) - - MapboxAccounts (2.2.0) - - MapboxCoreNavigation (0.40.0): - - MapboxAccounts (~> 2.2.0) - - MapboxDirections (~> 0.31.0) - - MapboxMobileEvents (~> 0.10.2) - - MapboxNavigationNative (~> 6.2.1) - - Turf (~> 0.3.0) - - MapboxDirections (0.31.1): - - Polyline (~> 4.2) - - Turf (~> 0.3.0) - - MapboxMobileEvents (0.10.2) - - MapboxNavigation (0.40.0): - - Mapbox-iOS-SDK (~> 5.6) - - MapboxCoreNavigation (= 0.40.0) - - MapboxMobileEvents (~> 0.10.2) - - MapboxSpeech (~> 0.3.0) - - Solar (~> 2.1) - - MapboxNavigationNative (6.2.1) - - MapboxSpeech (0.3.1) + - GoogleMapsXC (6.1.1-beta) + - MapboxCommon (21.2.0) + - MapboxCoreMaps (10.4.1): + - MapboxCommon (~> 21.2) + - MapboxMaps (10.4.1): + - MapboxCommon (= 21.2.0) + - MapboxCoreMaps (= 10.4.1) + - MapboxMobileEvents (= 1.0.7) + - Turf (~> 2.0) + - MapboxMobileEvents (1.0.7) + - MapBoxWrapper (10.4.1): + - MapboxMaps (= 10.4.1) - MultiPlatformLibrary (0.1.0) - - Polyline (4.2.1) - - Solar (2.1.0) - - Turf (0.3.0) + - Turf (2.3.0) DEPENDENCIES: - - GoogleMaps (= 3.7.0) - - Mapbox-iOS-SDK (= 5.6.0) - - MapboxNavigation (= 0.40.0) + - GoogleMapsXC (from `../../GoogleMapsXC.podspec`) + - MapBoxWrapper (from `../..`) - MultiPlatformLibrary (from `../mpp-library`) SPEC REPOS: trunk: - - GoogleMaps - - Mapbox-iOS-SDK - - MapboxAccounts - - MapboxCoreNavigation - - MapboxDirections + - MapboxCommon + - MapboxCoreMaps + - MapboxMaps - MapboxMobileEvents - - MapboxNavigation - - MapboxNavigationNative - - MapboxSpeech - - Polyline - - Solar - Turf EXTERNAL SOURCES: + GoogleMapsXC: + :podspec: "../../GoogleMapsXC.podspec" + MapBoxWrapper: + :path: "../.." MultiPlatformLibrary: :path: "../mpp-library" SPEC CHECKSUMS: - GoogleMaps: 55da829c68aa931f3ae982b9e341cc2f3d89c587 - Mapbox-iOS-SDK: 913c4655bd72a200f84996caf7a755b377abc77f - MapboxAccounts: f9716ba2cc66013e44ef93e0e16cfa1049f3aeec - MapboxCoreNavigation: 2856c46bd064bb11c406ba00191d579cda424efa - MapboxDirections: 69dca02d780c5e506bdcc65385dd5fb77b9e90b5 - MapboxMobileEvents: 2bc0ca2eedb627b73cf403258dce2b2fa98074a6 - MapboxNavigation: 42bae50b0381dce317c85884ba0de38fc68a4814 - MapboxNavigationNative: 11dc22140f4698d3f26989f2b6379dc81ef0d4c1 - MapboxSpeech: 67a558a672dc2b6266a993f4624895f69e58d105 + GoogleMapsXC: 2e3f87f4fbad69bc9cfd2dfecc14a0dfb3f1813b + MapboxCommon: eb826fdc45e8b77f87aca2519986d992fd4881b7 + MapboxCoreMaps: 13892567aa2a0e1cf8713887678f82998e2ff015 + MapboxMaps: 92e3eb21102beee5eca7cb4d9144162d6d1813c5 + MapboxMobileEvents: f7f3e8daeb4b83688ae62a4172dce79169a97233 + MapBoxWrapper: d952f9a084aea5299486eea8d94038d16a3bcf20 MultiPlatformLibrary: 176fb8ade516666cd47e93de1b71ba0441a541bb - Polyline: 0e9890790292741c8186201a536b6bb6a78d02dd - Solar: 2dc6e7cc39186cb0c8228fa08df76fb50c7d8f24 - Turf: c6bdf62d6a70c647874f295dd1cf4eefc0c3e9e6 + Turf: d8d52444483c968cf2d65b8b54640f8faf4dda03 -PODFILE CHECKSUM: d3f063e08a8b62545e8d3ca223d36ca3c67d1c9c +PODFILE CHECKSUM: 691d6710edfabbb8953cf43a7c96da641f6249a8 -COCOAPODS: 1.10.0 +COCOAPODS: 1.11.2 diff --git a/sample/ios-app/TestProj.xcodeproj/project.pbxproj b/sample/ios-app/TestProj.xcodeproj/project.pbxproj index e1d55ef..8af04ef 100644 --- a/sample/ios-app/TestProj.xcodeproj/project.pbxproj +++ b/sample/ios-app/TestProj.xcodeproj/project.pbxproj @@ -115,7 +115,6 @@ 287627FB1F319065007FA12B /* Sources */, 287627FC1F319065007FA12B /* Frameworks */, 287627FD1F319065007FA12B /* Resources */, - F79810AA1499C35699C9419C /* [CP] Copy Pods Resources */, D87BA21237AC9858A1A613E3 /* [CP] Embed Pods Frameworks */, ); buildRules = ( @@ -212,21 +211,6 @@ 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"; showEnvVarsInLog = 0; }; - F79810AA1499C35699C9419C /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputFileListPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-TestProj/Pods-TestProj-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ diff --git a/sample/mpp-library/build.gradle.kts b/sample/mpp-library/build.gradle.kts index 2268b59..688cf9f 100644 --- a/sample/mpp-library/build.gradle.kts +++ b/sample/mpp-library/build.gradle.kts @@ -1,29 +1,32 @@ +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget + plugins { - id("com.android.library") - id("android-base-convention") - id("detekt-convention") - id("org.jetbrains.kotlin.multiplatform") - id("dev.icerock.mobile.multiplatform.android-manifest") + id("dev.icerock.moko.gradle.multiplatform.mobile") + id("dev.icerock.moko.gradle.detekt") id("dev.icerock.mobile.multiplatform.ios-framework") id("dev.icerock.mobile.multiplatform-resources") id("dev.icerock.mobile.multiplatform.cocoapods") } -kotlin{ - android() - ios() -} +kotlin.targets.withType() + .matching { it.konanTarget.family == org.jetbrains.kotlin.konan.target.Family.IOS } + .configureEach { + compilations.all { + kotlinOptions.freeCompilerArgs += "-Xoverride-konan-properties=osVersionMin.ios_x64=12.0;osVersionMin.ios_arm64=12.0;osVersionMin.ios_simulator_arm64=14.0" + } + } dependencies { commonMainImplementation(libs.coroutines) commonMainImplementation(libs.mokoResources) commonMainApi(libs.mokoGeo) - commonMainApi(libs.mokoMvvm) + commonMainApi(libs.mokoMvvmCore) + commonMainApi(libs.mokoMvvmLiveData) commonMainApi(libs.mokoPermissions) commonMainApi(projects.maps) commonMainApi(projects.mapsGoogle) commonMainApi(projects.mapsMapbox) - "androidMainImplementation"(libs.lifecycle) + androidMainImplementation(libs.lifecycle) } multiplatformResources { @@ -41,16 +44,23 @@ cocoaPods { precompiledPod( scheme = "GoogleMaps", onlyLink = true - ) { podsDir -> + ) { podsDir, target -> + val sdkPath = when (target.konanTarget) { + is org.jetbrains.kotlin.konan.target.KonanTarget.IOS_SIMULATOR_ARM64, + is org.jetbrains.kotlin.konan.target.KonanTarget.IOS_X64 -> "ios-x86_64_arm64-simulator" + is org.jetbrains.kotlin.konan.target.KonanTarget.IOS_ARM64 -> "ios-arm64" + else -> throw IllegalArgumentException("invalid target $target") + } listOf( - File(podsDir, "GoogleMaps/Base/Frameworks"), - File(podsDir, "GoogleMaps/Maps/Frameworks") - ) + "GoogleMapsBase", + "GoogleMapsCore", + "GoogleMaps" + ).map { File(podsDir, "GoogleMapsXC/$it.xcframework/$sdkPath") } } precompiledPod( scheme = "Mapbox", onlyLink = true - ) { podsDir -> + ) { podsDir, _ -> listOf(File(podsDir, "Mapbox-iOS-SDK/dynamic")) } } diff --git a/settings.gradle.kts b/settings.gradle.kts index 697b2c0..0b7072a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -24,17 +24,9 @@ dependencyResolutionManagement { ?: extra["mapbox.secretToken"] as? String } } - - jcenter { - content { - includeGroup("org.jetbrains.kotlinx") - } - } } } -includeBuild("maps-build-logic") - include(":maps") include(":maps-google") include(":maps-mapbox")