From c09b344c0345ce82742af6c6614ae1db4ae630b4 Mon Sep 17 00:00:00 2001 From: Ivan Matkov Date: Mon, 24 Jul 2023 18:15:44 +0200 Subject: [PATCH 1/5] Adopt ImageViewer to Compose 1.5.0-dev1114 and Kotlin 1.9.0 (#3400) * ImageViewer. Add WindowsInsets.ime and update resources * Update gradle properties * Fix HorizontalPager usage * Add ExperimentalForeignApi annotation --------- Co-authored-by: dima.avdeev --- examples/imageviewer/README.md | 3 ++ examples/imageviewer/gradle.properties | 4 +-- .../example/imageviewer/platform.android.kt | 2 -- .../example/imageviewer/platform.common.kt | 2 -- .../example/imageviewer/view/GalleryScreen.kt | 8 ++++-- .../example/imageviewer/view/TopLayout.kt | 6 ++-- .../example/imageviewer/platform.desktop.kt | 2 -- .../example/imageviewer/platform.ios.kt | 28 ++----------------- .../imageviewer/storage/FileExtensions.kt | 2 ++ .../storage/IosImageStorage.ios.kt | 3 ++ .../imageviewer/view/CameraView.ios.kt | 3 ++ .../view/LocationVisualizer.ios.kt | 2 ++ 12 files changed, 27 insertions(+), 38 deletions(-) diff --git a/examples/imageviewer/README.md b/examples/imageviewer/README.md index ed9fd665e9c..6b2a834eed9 100755 --- a/examples/imageviewer/README.md +++ b/examples/imageviewer/README.md @@ -9,6 +9,9 @@ To setup the environment, please consult these [instructions](https://github.com ## How to run +If you already runned this sample before, then you need to execute command at least once: +`/gradlew podInstall` + Choose a run configuration for an appropriate target in IDE and run it. ![run-configurations.png](screenshots/run-configurations.png) diff --git a/examples/imageviewer/gradle.properties b/examples/imageviewer/gradle.properties index ed81b24b3f1..ae8c087e064 100644 --- a/examples/imageviewer/gradle.properties +++ b/examples/imageviewer/gradle.properties @@ -11,6 +11,6 @@ kotlin.mpp.androidSourceSetLayoutVersion=2 kotlin.native.useEmbeddableCompilerJar=true # Enable kotlin/native experimental memory model kotlin.native.binary.memoryModel=experimental -kotlin.version=1.8.20 +kotlin.version=1.9.0 agp.version=7.1.3 -compose.version=1.4.1 +compose.version=1.5.0-dev1114 diff --git a/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/platform.android.kt b/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/platform.android.kt index 21fb2cdcb59..ca508bfed27 100644 --- a/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/platform.android.kt +++ b/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/platform.android.kt @@ -10,8 +10,6 @@ import androidx.compose.ui.graphics.vector.ImageVector import kotlinx.coroutines.Dispatchers import java.util.UUID -actual fun Modifier.notchPadding(): Modifier = this.displayCutoutPadding().statusBarsPadding() - class AndroidStorableImage( val imageBitmap: ImageBitmap ) diff --git a/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/platform.common.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/platform.common.kt index a1bc1acc811..532a29bdfe1 100644 --- a/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/platform.common.kt +++ b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/platform.common.kt @@ -4,8 +4,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector import kotlinx.coroutines.CoroutineDispatcher -expect fun Modifier.notchPadding(): Modifier - expect class PlatformStorableImage expect fun createUUID(): String diff --git a/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/GalleryScreen.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/GalleryScreen.kt index a161f5ee937..07302cd2793 100755 --- a/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/GalleryScreen.kt +++ b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/GalleryScreen.kt @@ -56,7 +56,11 @@ fun GalleryScreen( val imageProvider = LocalImageProvider.current val viewScope = rememberCoroutineScope() - val pagerState = rememberPagerState(initialPage = selectedPictureIndex.value) + val pagerState = rememberPagerState( + initialPage = selectedPictureIndex.value, + initialPageOffsetFraction = 0f, + pageCount = { pictures.size }, + ) LaunchedEffect(pagerState) { // Subscribe to page changes snapshotFlow { pagerState.currentPage }.collect { page -> @@ -116,7 +120,7 @@ fun GalleryScreen( onClickPreviewPicture(pagerState.currentPage) } ) { - HorizontalPager(pictures.size, state = pagerState) { index -> + HorizontalPager(state = pagerState) { index -> val picture = pictures[index] var image: ImageBitmap? by remember(picture) { mutableStateOf(null) } LaunchedEffect(picture) { diff --git a/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/TopLayout.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/TopLayout.kt index 1e2a0a059d3..57d6328ced5 100644 --- a/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/TopLayout.kt +++ b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/TopLayout.kt @@ -2,13 +2,15 @@ package example.imageviewer.view import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.systemBars +import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp -import example.imageviewer.notchPadding @Composable fun TopLayout( @@ -18,7 +20,7 @@ fun TopLayout( Box( Modifier .fillMaxWidth() - .notchPadding() + .windowInsetsPadding(WindowInsets.systemBars) .padding(12.dp) ) { Row(Modifier.align(Alignment.CenterStart)) { diff --git a/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/platform.desktop.kt b/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/platform.desktop.kt index e9afee75af3..d592f8aeb94 100644 --- a/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/platform.desktop.kt +++ b/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/platform.desktop.kt @@ -10,8 +10,6 @@ import androidx.compose.ui.unit.dp import kotlinx.coroutines.Dispatchers import java.util.UUID -actual fun Modifier.notchPadding(): Modifier = Modifier.padding(top = 12.dp) - class DesktopStorableImage( val imageBitmap: ImageBitmap ) diff --git a/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/platform.ios.kt b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/platform.ios.kt index 9926f5250ca..711d3cb3853 100644 --- a/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/platform.ios.kt +++ b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/platform.ios.kt @@ -1,46 +1,22 @@ package example.imageviewer -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.windowInsetsPadding -import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector -import androidx.compose.ui.unit.Density -import androidx.compose.ui.unit.LayoutDirection import example.imageviewer.icon.IconIosShare -import kotlinx.cinterop.useContents +import kotlinx.cinterop.ExperimentalForeignApi import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.IO import platform.CoreFoundation.CFUUIDCreate import platform.CoreFoundation.CFUUIDCreateString import platform.Foundation.CFBridgingRelease -import platform.UIKit.UIApplication import platform.UIKit.UIImage -private val iosNotchInset = object : WindowInsets { - override fun getTop(density: Density): Int { - val safeAreaInsets = UIApplication.sharedApplication.keyWindow?.safeAreaInsets - return if (safeAreaInsets != null) { - val topInset = safeAreaInsets.useContents { this.top } - (topInset * density.density).toInt() - } else { - 0 - } - } - - override fun getLeft(density: Density, layoutDirection: LayoutDirection): Int = 0 - override fun getRight(density: Density, layoutDirection: LayoutDirection): Int = 0 - override fun getBottom(density: Density): Int = 0 -} - -actual fun Modifier.notchPadding(): Modifier = - this.windowInsetsPadding(iosNotchInset) - class IosStorableImage( val rawValue: UIImage ) actual typealias PlatformStorableImage = IosStorableImage +@OptIn(ExperimentalForeignApi::class) actual fun createUUID(): String = CFBridgingRelease(CFUUIDCreateString(null, CFUUIDCreate(null))) as String diff --git a/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/FileExtensions.kt b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/FileExtensions.kt index 3513a1f6623..a0030271603 100644 --- a/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/FileExtensions.kt +++ b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/FileExtensions.kt @@ -1,3 +1,5 @@ +@file:OptIn(ExperimentalForeignApi::class) + package example.imageviewer.storage import kotlinx.cinterop.* diff --git a/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt index 93408a61d18..59b0d7c1be5 100644 --- a/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt +++ b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt @@ -7,6 +7,7 @@ import example.imageviewer.PlatformStorableImage import example.imageviewer.model.PictureData import example.imageviewer.toImageBitmap import kotlinx.cinterop.CValue +import kotlinx.cinterop.ExperimentalForeignApi import kotlinx.cinterop.useContents import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -122,6 +123,7 @@ class IosImageStorage( } } +@OptIn(ExperimentalForeignApi::class) private fun UIImage.fitInto(px: Int): UIImage { val targetScale = maxOf( px.toFloat() / size.useContents { width }, @@ -131,6 +133,7 @@ private fun UIImage.fitInto(px: Int): UIImage { return resize(newSize) } +@OptIn(ExperimentalForeignApi::class) private fun UIImage.resize(targetSize: CValue): UIImage { val currentSize = this.size val widthRatio = targetSize.useContents { width } / currentSize.useContents { width } diff --git a/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/CameraView.ios.kt b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/CameraView.ios.kt index c76d44fa88d..5499750fba6 100644 --- a/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/CameraView.ios.kt +++ b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/CameraView.ios.kt @@ -18,6 +18,7 @@ import example.imageviewer.model.GpsPosition import example.imageviewer.model.PictureData import example.imageviewer.model.createCameraPictureData import kotlinx.cinterop.CValue +import kotlinx.cinterop.ExperimentalForeignApi import kotlinx.cinterop.ObjCAction import kotlinx.cinterop.useContents import platform.AVFoundation.* @@ -121,6 +122,7 @@ private fun BoxScope.AuthorizedCamera( } } +@OptIn(ExperimentalForeignApi::class) @Composable private fun BoxScope.RealDeviceCamera( camera: AVCaptureDevice, @@ -272,6 +274,7 @@ private fun BoxScope.RealDeviceCamera( } } +@OptIn(ExperimentalForeignApi::class) fun CLLocation.toGps() = GpsPosition( latitude = coordinate.useContents { latitude }, diff --git a/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/LocationVisualizer.ios.kt b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/LocationVisualizer.ios.kt index 451d3b9ee5e..4da53ef73b6 100644 --- a/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/LocationVisualizer.ios.kt +++ b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/LocationVisualizer.ios.kt @@ -6,11 +6,13 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.interop.UIKitView import example.imageviewer.model.GpsPosition +import kotlinx.cinterop.ExperimentalForeignApi import platform.CoreLocation.CLLocationCoordinate2DMake import platform.MapKit.MKCoordinateRegionMakeWithDistance import platform.MapKit.MKMapView import platform.MapKit.MKPointAnnotation +@OptIn(ExperimentalForeignApi::class) @Composable actual fun LocationVisualizer( modifier: Modifier, From 9438837cc1f073d2a06236b072aa4908a7f10eda Mon Sep 17 00:00:00 2001 From: Igor Demin Date: Mon, 24 Jul 2023 18:47:08 +0200 Subject: [PATCH 2/5] ImageViewer. Reenable build on CI (#3385) The CI checks was disabled in https://github.com/JetBrains/compose-multiplatform/pull/3384. Reenable them in support/1.5.0, which will be merged after the 1.5.0 release. --- examples/validateExamples.sh | 2 +- examples/validateExamplesAndroid.sh | 2 +- examples/validateExamplesIos.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/validateExamples.sh b/examples/validateExamples.sh index d46861cdb0e..6925f607d02 100755 --- a/examples/validateExamples.sh +++ b/examples/validateExamples.sh @@ -21,7 +21,7 @@ runGradle() { runGradle chat packageDistributionForCurrentOS runGradle codeviewer packageDistributionForCurrentOS -#runGradle imageviewer packageDistributionForCurrentOS +runGradle imageviewer packageDistributionForCurrentOS runGradle issues packageDistributionForCurrentOS runGradle notepad packageDistributionForCurrentOS runGradle todoapp-lite packageDistributionForCurrentOS diff --git a/examples/validateExamplesAndroid.sh b/examples/validateExamplesAndroid.sh index a526d7e1107..24d077f496f 100644 --- a/examples/validateExamplesAndroid.sh +++ b/examples/validateExamplesAndroid.sh @@ -22,7 +22,7 @@ runGradle() { # requires an emulator running or an Android device to be connected runGradle chat installDebug runGradle codeviewer installDebug -#runGradle imageviewer installDebug +runGradle imageviewer installDebug runGradle issues installDebug runGradle minesweeper installDebug runGradle todoapp-lite installDebug diff --git a/examples/validateExamplesIos.sh b/examples/validateExamplesIos.sh index d2162f697d7..6da14bb2106 100755 --- a/examples/validateExamplesIos.sh +++ b/examples/validateExamplesIos.sh @@ -34,7 +34,7 @@ runGradle() { runGradle chat runGradle codeviewer runGradle falling-balls -# runGradle imageviewer +runGradle imageviewer runGradle todoapp-lite runGradle visual-effects runGradle widgets-gallery From 6d88ec2220f1b6620789a16a77173150ee8a185d Mon Sep 17 00:00:00 2001 From: Igor Demin Date: Mon, 14 Aug 2023 03:04:03 +0200 Subject: [PATCH 3/5] 1.5.0-beta02 Changelog (#3483) --- CHANGELOG.md | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cc0e921533..823fbd66233 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,58 @@ +# 1.5.0-beta02 (August 2023) + +## Common + +### Features +- [`androidx.compose.material.DropdownMenu` is available to use from common source set](https://github.com/JetBrains/compose-multiplatform-core/pull/738) +- [`androidx.compose.material3.DropdownMenu` is available to use from common source set](https://github.com/JetBrains/compose-multiplatform-core/pull/737) +- [`androidx.compose.material.AlertDialog` is available to use from common source set](https://github.com/JetBrains/compose-multiplatform-core/pull/708) +- [`androidx.compose.material3.AlertDialog` is available to use from common source set](https://github.com/JetBrains/compose-multiplatform-core/pull/710) +- [Add `PopupProperties.clippingEnabled` setting](https://github.com/JetBrains/compose-multiplatform-core/pull/740) +- material3. Support [`DatePicker`](https://github.com/JetBrains/compose-multiplatform-core/pull/717), [`DatePickerDialog`](https://github.com/JetBrains/compose-multiplatform-core/pull/745) and `TimePicker` + +### API Changes +- [Change the default layout behavior of `AlertDialog`](https://github.com/JetBrains/compose-multiplatform-core/pull/708) + +## iOS + +### Features +- [Support singleLine and `KeyboardAction`](https://github.com/JetBrains/compose-multiplatform-core/pull/699) + +### Fixes +- [Fix memory leak in `ComposeUIViewController`](https://github.com/JetBrains/compose-multiplatform/issues/3201) +- [Manage Kotlin native cache kind automatically based on Kotlin version](https://github.com/JetBrains/compose-multiplatform/pull/3477) (`kotlin.native.cacheKind=none` is no longer needed) +- [Limit max `Dialog` and `Popup` size by safe area on iOS](https://github.com/JetBrains/compose-multiplatform-core/pull/732) +- [`TextField`, Korean characters are not normally entered](https://github.com/JetBrains/compose-multiplatform/issues/3101) +- [`ColorMatrix` value range for 5th column was incorrect on Skiko backed platforms](https://github.com/JetBrains/compose-multiplatform/issues/3461) +- [`isSystemDarkTheme` now automatically react to the system theme changes](https://github.com/JetBrains/compose-multiplatform-core/pull/715) + +### API Changes +- [`ComposeUIViewController`. Dispose composition on `viewDidDisappear`](https://github.com/JetBrains/compose-multiplatform-core/pull/747) + +## Web + +### Features +- [Make `CanvasBasedWindow` apply default styles, set title](https://github.com/JetBrains/compose-multiplatform-core/pull/722) + +## Gradle Plugin + +### Features +- [Add `runtimeSaveable` to Dependencies in compose gradle plugin](https://github.com/JetBrains/compose-multiplatform/pull/3449) + +### API Changes +- [Raise error when Homebrew JDK is used for packaging](https://github.com/JetBrains/compose-multiplatform/pull/3451/files) + +## Dependencies + +This version of Compose Multiplatform is based on the next Jetpack Compose libraries: + +- [Compiler 1.5.0](https://developer.android.com/jetpack/androidx/releases/compose-compiler#1.5.0) +- [Runtime 1.5.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.5.0) +- [UI 1.5.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.5.0) +- [Foundation 1.5.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.5.0) +- [Material 1.5.0](https://developer.android.com/jetpack/androidx/releases/compose-material#1.5.0) +- [Material3 1.1.1](https://developer.android.com/jetpack/androidx/releases/compose-material3#1.1.1) + # 1.5.0-beta01 (July 2023) ## Common From fa2df40e115096a243ed7e993b9b9648b0424fdd Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov <654232+AlexeyTsvetkov@users.noreply.github.com> Date: Tue, 15 Aug 2023 19:49:58 +0200 Subject: [PATCH 4/5] Replace warnings with errors (#3496) --- examples/chat/gradle.properties | 3 +-- examples/chat/shared/build.gradle.kts | 1 - examples/codeviewer/gradle.properties | 3 +-- examples/codeviewer/shared/build.gradle.kts | 1 - examples/falling-balls/gradle.properties | 3 +-- examples/falling-balls/shared/build.gradle.kts | 1 - examples/imageviewer/gradle.properties | 3 +-- examples/imageviewer/shared/build.gradle.kts | 2 -- examples/minesweeper/gradle.properties | 3 +-- examples/minesweeper/shared/build.gradle.kts | 12 +----------- examples/todoapp-lite/gradle.properties | 3 +-- examples/todoapp-lite/shared/build.gradle.kts | 1 - examples/visual-effects/gradle.properties | 3 +-- examples/visual-effects/shared/build.gradle.kts | 1 - examples/widgets-gallery/gradle.properties | 3 +-- examples/widgets-gallery/shared/build.gradle.kts | 1 - .../internal/configureNativeCompilerCaching.kt | 8 +++----- .../resources/configureSyncIosResources.kt | 6 +++++- .../test/tests/integration/GradlePluginTest.kt | 14 +++++--------- 19 files changed, 22 insertions(+), 50 deletions(-) diff --git a/examples/chat/gradle.properties b/examples/chat/gradle.properties index 0c5787e9692..8390fbc4874 100644 --- a/examples/chat/gradle.properties +++ b/examples/chat/gradle.properties @@ -6,11 +6,10 @@ org.gradle.jvmargs=-Xmx3g org.jetbrains.compose.experimental.jscanvas.enabled=true org.jetbrains.compose.experimental.macos.enabled=true org.jetbrains.compose.experimental.uikit.enabled=true -kotlin.native.cacheKind=none kotlin.native.useEmbeddableCompilerJar=true kotlin.mpp.androidSourceSetLayoutVersion=2 # Enable kotlin/native experimental memory model kotlin.native.binary.memoryModel=experimental kotlin.version=1.9.0 agp.version=7.1.3 -compose.version=1.4.3 +compose.version=1.5.0-beta02 diff --git a/examples/chat/shared/build.gradle.kts b/examples/chat/shared/build.gradle.kts index 9d553b73b5f..f1bab781b97 100644 --- a/examples/chat/shared/build.gradle.kts +++ b/examples/chat/shared/build.gradle.kts @@ -45,7 +45,6 @@ kotlin { baseName = "shared" isStatic = true } - extraSpecAttributes["resources"] = "['src/commonMain/resources/**', 'src/iosMain/resources/**']" } sourceSets { diff --git a/examples/codeviewer/gradle.properties b/examples/codeviewer/gradle.properties index 0c5787e9692..8390fbc4874 100644 --- a/examples/codeviewer/gradle.properties +++ b/examples/codeviewer/gradle.properties @@ -6,11 +6,10 @@ org.gradle.jvmargs=-Xmx3g org.jetbrains.compose.experimental.jscanvas.enabled=true org.jetbrains.compose.experimental.macos.enabled=true org.jetbrains.compose.experimental.uikit.enabled=true -kotlin.native.cacheKind=none kotlin.native.useEmbeddableCompilerJar=true kotlin.mpp.androidSourceSetLayoutVersion=2 # Enable kotlin/native experimental memory model kotlin.native.binary.memoryModel=experimental kotlin.version=1.9.0 agp.version=7.1.3 -compose.version=1.4.3 +compose.version=1.5.0-beta02 diff --git a/examples/codeviewer/shared/build.gradle.kts b/examples/codeviewer/shared/build.gradle.kts index d08dcbaef29..526c6f61b27 100644 --- a/examples/codeviewer/shared/build.gradle.kts +++ b/examples/codeviewer/shared/build.gradle.kts @@ -26,7 +26,6 @@ kotlin { baseName = "shared" isStatic = true } - extraSpecAttributes["resources"] = "['src/commonMain/resources/**', 'src/iosMain/resources/**']" } sourceSets { diff --git a/examples/falling-balls/gradle.properties b/examples/falling-balls/gradle.properties index 0c5787e9692..8390fbc4874 100644 --- a/examples/falling-balls/gradle.properties +++ b/examples/falling-balls/gradle.properties @@ -6,11 +6,10 @@ org.gradle.jvmargs=-Xmx3g org.jetbrains.compose.experimental.jscanvas.enabled=true org.jetbrains.compose.experimental.macos.enabled=true org.jetbrains.compose.experimental.uikit.enabled=true -kotlin.native.cacheKind=none kotlin.native.useEmbeddableCompilerJar=true kotlin.mpp.androidSourceSetLayoutVersion=2 # Enable kotlin/native experimental memory model kotlin.native.binary.memoryModel=experimental kotlin.version=1.9.0 agp.version=7.1.3 -compose.version=1.4.3 +compose.version=1.5.0-beta02 diff --git a/examples/falling-balls/shared/build.gradle.kts b/examples/falling-balls/shared/build.gradle.kts index 11a8ee85602..8716294172d 100644 --- a/examples/falling-balls/shared/build.gradle.kts +++ b/examples/falling-balls/shared/build.gradle.kts @@ -45,7 +45,6 @@ kotlin { baseName = "shared" isStatic = true } - extraSpecAttributes["resources"] = "['src/commonMain/resources/**', 'src/iosMain/resources/**']" } sourceSets { diff --git a/examples/imageviewer/gradle.properties b/examples/imageviewer/gradle.properties index ae8c087e064..efa38e2e33d 100644 --- a/examples/imageviewer/gradle.properties +++ b/examples/imageviewer/gradle.properties @@ -6,11 +6,10 @@ org.gradle.jvmargs=-Xmx3g org.jetbrains.compose.experimental.jscanvas.enabled=true org.jetbrains.compose.experimental.macos.enabled=true org.jetbrains.compose.experimental.uikit.enabled=true -kotlin.native.cacheKind=none kotlin.mpp.androidSourceSetLayoutVersion=2 kotlin.native.useEmbeddableCompilerJar=true # Enable kotlin/native experimental memory model kotlin.native.binary.memoryModel=experimental kotlin.version=1.9.0 agp.version=7.1.3 -compose.version=1.5.0-dev1114 +compose.version=1.5.0-beta02 diff --git a/examples/imageviewer/shared/build.gradle.kts b/examples/imageviewer/shared/build.gradle.kts index 49db30760d9..5a3e685b833 100755 --- a/examples/imageviewer/shared/build.gradle.kts +++ b/examples/imageviewer/shared/build.gradle.kts @@ -26,8 +26,6 @@ kotlin { baseName = "shared" isStatic = true } - extraSpecAttributes["resources"] = "['src/commonMain/resources/**', 'src/iosMain/resources/**']" - } sourceSets { diff --git a/examples/minesweeper/gradle.properties b/examples/minesweeper/gradle.properties index 0c5787e9692..8390fbc4874 100644 --- a/examples/minesweeper/gradle.properties +++ b/examples/minesweeper/gradle.properties @@ -6,11 +6,10 @@ org.gradle.jvmargs=-Xmx3g org.jetbrains.compose.experimental.jscanvas.enabled=true org.jetbrains.compose.experimental.macos.enabled=true org.jetbrains.compose.experimental.uikit.enabled=true -kotlin.native.cacheKind=none kotlin.native.useEmbeddableCompilerJar=true kotlin.mpp.androidSourceSetLayoutVersion=2 # Enable kotlin/native experimental memory model kotlin.native.binary.memoryModel=experimental kotlin.version=1.9.0 agp.version=7.1.3 -compose.version=1.4.3 +compose.version=1.5.0-beta02 diff --git a/examples/minesweeper/shared/build.gradle.kts b/examples/minesweeper/shared/build.gradle.kts index 1c97c2dd076..430c4f31f73 100644 --- a/examples/minesweeper/shared/build.gradle.kts +++ b/examples/minesweeper/shared/build.gradle.kts @@ -15,16 +15,7 @@ kotlin { jvm("desktop") ios() - iosSimulatorArm64() { - // TODO: remove after 1.5 release - binaries.forEach { - it.freeCompilerArgs += listOf( - "-linker-option", "-framework", "-linker-option", "Metal", - "-linker-option", "-framework", "-linker-option", "CoreText", - "-linker-option", "-framework", "-linker-option", "CoreGraphics", - ) - } - } + iosSimulatorArm64() js(IR) { browser() @@ -54,7 +45,6 @@ kotlin { baseName = "shared" isStatic = true } - extraSpecAttributes["resources"] = "['src/commonMain/resources/**', 'src/iosMain/resources/**']" } sourceSets { diff --git a/examples/todoapp-lite/gradle.properties b/examples/todoapp-lite/gradle.properties index 0c5787e9692..8390fbc4874 100755 --- a/examples/todoapp-lite/gradle.properties +++ b/examples/todoapp-lite/gradle.properties @@ -6,11 +6,10 @@ org.gradle.jvmargs=-Xmx3g org.jetbrains.compose.experimental.jscanvas.enabled=true org.jetbrains.compose.experimental.macos.enabled=true org.jetbrains.compose.experimental.uikit.enabled=true -kotlin.native.cacheKind=none kotlin.native.useEmbeddableCompilerJar=true kotlin.mpp.androidSourceSetLayoutVersion=2 # Enable kotlin/native experimental memory model kotlin.native.binary.memoryModel=experimental kotlin.version=1.9.0 agp.version=7.1.3 -compose.version=1.4.3 +compose.version=1.5.0-beta02 diff --git a/examples/todoapp-lite/shared/build.gradle.kts b/examples/todoapp-lite/shared/build.gradle.kts index fff63d294bc..c2e8dde553e 100755 --- a/examples/todoapp-lite/shared/build.gradle.kts +++ b/examples/todoapp-lite/shared/build.gradle.kts @@ -26,7 +26,6 @@ kotlin { baseName = "shared" isStatic = true } - extraSpecAttributes["resources"] = "['src/commonMain/resources/**', 'src/iosMain/resources/**']" } sourceSets { diff --git a/examples/visual-effects/gradle.properties b/examples/visual-effects/gradle.properties index 125fb440559..5b9eda536a9 100644 --- a/examples/visual-effects/gradle.properties +++ b/examples/visual-effects/gradle.properties @@ -7,10 +7,9 @@ org.jetbrains.compose.experimental.jscanvas.enabled=true org.jetbrains.compose.experimental.macos.enabled=true org.jetbrains.compose.experimental.uikit.enabled=true kotlin.mpp.androidSourceSetLayoutVersion=2 -kotlin.native.cacheKind=none kotlin.native.useEmbeddableCompilerJar=true # Enable kotlin/native experimental memory model kotlin.native.binary.memoryModel=experimental kotlin.version=1.9.0 agp.version=7.1.3 -compose.version=1.4.3 +compose.version=1.5.0-beta02 diff --git a/examples/visual-effects/shared/build.gradle.kts b/examples/visual-effects/shared/build.gradle.kts index de48622f63b..04eec1a4e90 100644 --- a/examples/visual-effects/shared/build.gradle.kts +++ b/examples/visual-effects/shared/build.gradle.kts @@ -24,7 +24,6 @@ kotlin { baseName = "shared" isStatic = true } - extraSpecAttributes["resources"] = "['src/commonMain/resources/**', 'src/iosMain/resources/**']" } sourceSets { diff --git a/examples/widgets-gallery/gradle.properties b/examples/widgets-gallery/gradle.properties index 0c5787e9692..8390fbc4874 100644 --- a/examples/widgets-gallery/gradle.properties +++ b/examples/widgets-gallery/gradle.properties @@ -6,11 +6,10 @@ org.gradle.jvmargs=-Xmx3g org.jetbrains.compose.experimental.jscanvas.enabled=true org.jetbrains.compose.experimental.macos.enabled=true org.jetbrains.compose.experimental.uikit.enabled=true -kotlin.native.cacheKind=none kotlin.native.useEmbeddableCompilerJar=true kotlin.mpp.androidSourceSetLayoutVersion=2 # Enable kotlin/native experimental memory model kotlin.native.binary.memoryModel=experimental kotlin.version=1.9.0 agp.version=7.1.3 -compose.version=1.4.3 +compose.version=1.5.0-beta02 diff --git a/examples/widgets-gallery/shared/build.gradle.kts b/examples/widgets-gallery/shared/build.gradle.kts index 1179c0907ec..85ddf1493cf 100644 --- a/examples/widgets-gallery/shared/build.gradle.kts +++ b/examples/widgets-gallery/shared/build.gradle.kts @@ -26,7 +26,6 @@ kotlin { baseName = "shared" isStatic = true } - extraSpecAttributes["resources"] = "['src/commonMain/resources/**', 'src/iosMain/resources/**']" } sourceSets { diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/internal/configureNativeCompilerCaching.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/internal/configureNativeCompilerCaching.kt index 55e3a440a09..7537f89bffb 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/internal/configureNativeCompilerCaching.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/internal/configureNativeCompilerCaching.kt @@ -46,9 +46,7 @@ private fun KotlinNativeTarget.checkCacheKindUserValueIsNotNone() { val value = provider.valueOrNull(cacheKindProperty) if (value != null) { if (value.equals(NONE_VALUE, ignoreCase = true)) { - ComposeMultiplatformBuildService - .getInstance(project) - .warnOnceAfterBuild(cacheKindPropertyWarningMessage(cacheKindProperty, provider)) + error(cacheKindPropertyWarningMessage(cacheKindProperty, provider)) } return } @@ -60,13 +58,13 @@ private fun cacheKindPropertyWarningMessage( cacheKindProperty: String, provider: KGPPropertyProvider ) = """ - |Warning: '$cacheKindProperty' is explicitly set to `none`. + |'$cacheKindProperty' is explicitly set to `none`. |This option significantly slows the Kotlin/Native compiler. |Compose Multiplatform Gradle plugin can set this property automatically, |when it is necessary. | * Recommended action: remove explicit '$cacheKindProperty=$NONE_VALUE' from ${provider.location}. | * Alternative action: if you are sure you need '$cacheKindProperty=$NONE_VALUE', disable - |this warning by adding '$COMPOSE_NATIVE_MANAGE_CACHE_KIND=false' to your 'gradle.properties'. + |this error by adding '$COMPOSE_NATIVE_MANAGE_CACHE_KIND=false' to your 'gradle.properties'. """.trimMargin() private fun KotlinNativeTarget.configureTargetCompilerCache(kotlinVersion: KotlinVersion) { diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/resources/configureSyncIosResources.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/resources/configureSyncIosResources.kt index e640f8e9bad..ae0a430a088 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/resources/configureSyncIosResources.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/resources/configureSyncIosResources.kt @@ -92,7 +92,11 @@ private fun SyncIosResourcesContext.configureCocoapodsResourcesAttribute() { val specAttributes = cocoapodsExt.extraSpecAttributes val resourcesSpec = specAttributes[RESOURCES_SPEC_ATTR] if (!resourcesSpec.isNullOrBlank()) { - project.logger.warn("Warning: kotlin.cocoapods.extraSpecAttributes[\"resources\"] is ignored by Compose Multiplatform's resource synchronization for iOS") + error(""" + |Kotlin.cocoapods.extraSpecAttributes["resources"] is not compatible with Compose Multiplatform's resources management for iOS. + | * Recommended action: remove extraSpecAttributes["resources"] from '${project.buildFile}' and run '${project.path}:podInstall' once; + | * Alternative action: turn off Compose Multiplatform's resources management for iOS by adding '${IosGradleProperties.SYNC_RESOURCES_PROPERTY}=false' to your gradle.properties; + """.trimMargin()) } cocoapodsExt.framework { val syncDir = syncDirFor(this).get().asFile diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt index f2cd0db71a2..301f04f5754 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt @@ -142,23 +142,19 @@ class GradlePluginTest : GradlePluginTestBase() { defaultTestEnvironment.copy(kotlinVersion = kotlinVersion) ) - val cacheKindWarning = "Warning: 'kotlin.native.cacheKind' is explicitly set to `none`" + val cacheKindError = "'kotlin.native.cacheKind' is explicitly set to `none`" val args = arrayOf("build", "--dry-run", "-Pkotlin.native.cacheKind=none") with(nativeCacheKindWarningProject(kotlinVersion = TestKotlinVersions.v1_8_20)) { - gradle(*args).checks { - check.logContainsOnce(cacheKindWarning) - } - // check that the warning is shown even when the configuration is loaded from cache - gradle(*args).checks { - check.logContainsOnce(cacheKindWarning) + gradleFailure(*args).checks { + check.logContains(cacheKindError) } } testWorkDir.deleteRecursively() testWorkDir.mkdirs() with(nativeCacheKindWarningProject(kotlinVersion = TestKotlinVersions.v1_9_0) ) { - gradle(*args).checks { - check.logContainsOnce(cacheKindWarning) + gradleFailure(*args).checks { + check.logContains(cacheKindError) } } } From 72cccc66bc80c6f528870e9054544113317ecce0 Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov <654232+AlexeyTsvetkov@users.noreply.github.com> Date: Tue, 15 Aug 2023 20:00:06 +0200 Subject: [PATCH 5/5] Rename compose.ios.resources.sync flag (#3498) --- .../experimental/uikit/internal/utils/IosGradleProperties.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/utils/IosGradleProperties.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/utils/IosGradleProperties.kt index fa5829b21d4..0259e89758f 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/utils/IosGradleProperties.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/utils/IosGradleProperties.kt @@ -11,7 +11,7 @@ import org.jetbrains.compose.internal.utils.valueOrNull import org.jetbrains.compose.internal.utils.toBooleanProvider internal object IosGradleProperties { - const val SYNC_RESOURCES_PROPERTY = "org.jetbrains.compose.ios.resources.sync" + const val SYNC_RESOURCES_PROPERTY = "compose.ios.resources.sync" fun syncResources(providers: ProviderFactory): Provider = providers.valueOrNull(SYNC_RESOURCES_PROPERTY).toBooleanProvider(true)