Skip to content

Commit c696a6e

Browse files
committed
2.3.0-1.10.0-rc02-6
- Fixes `Processor` bug when fetching annotations parameters
1 parent 72428c5 commit c696a6e

File tree

8 files changed

+37
-18
lines changed

8 files changed

+37
-18
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [2.3.0-1.10.0-rc02-6]
4+
5+
- Fixes `Processor` bug when fetching annotations parameters
6+
7+
---
8+
39
## [2.3.0-1.10.0-rc02-5]
410

511
- Adds `opaque` property to `@ComposeUIViewController` to activate `ComposeUIViewController` `opaque` configuration.

CHANGELOG_PLUGIN.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [2.3.0-1.10.0-rc02-6]
4+
5+
- Compatible with 2.3.0-1.10.0-rc02-6
6+
7+
---
8+
39
## [2.3.0-1.10.0-rc02-5]
410

511
- Compatible with 2.3.0-1.10.0-rc02-5

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ KSP library and Gradle plugin for generating `ComposeUIViewController` and `UIVi
66

77
| Version | Kotlin | KSP | Compose Multiplatform | Xcode |
88
|-----------------------|:------:|:-----:|:---------------------:|:------:|
9-
| `2.3.0-1.10.0-rc02-5` | 2.3.0 | 2.3.4 | 1.10.0-rc02 | 26.2.0 |
9+
| `2.3.0-1.10.0-rc02-6` | 2.3.0 | 2.3.4 | 1.10.0-rc02 | 26.2.0 |
1010

1111
[![Android Weekly](https://androidweekly.net/issues/issue-583/badge)](https://androidweekly.net/issues/issue-583) [![Featured in Kotlin Weekly - Issue #378](https://img.shields.io/badge/Featured_in_Kotlin_Weekly-Issue_%23378-7878b4)](https://mailchi.mp/kotlinweekly/kotlin-weekly-378) [![Featured in Kotlin Weekly - Issue #389](https://img.shields.io/badge/Featured_in_Kotlin_Weekly-Issue_%23389-7878b4)](https://mailchi.mp/kotlinweekly/kotlin-weekly-389) <a href="https://jetc.dev/issues/177.html"><img src="https://img.shields.io/badge/As_Seen_In-jetc.dev_Newsletter_Issue_%23177-blue?logo=Jetpack+Compose&amp;logoColor=white" alt="As Seen In - jetc.dev Newsletter Issue #177"></a> <a href="https://jetc.dev/issues/188.html"><img src="https://img.shields.io/badge/As_Seen_In-jetc.dev_Newsletter_Issue_%23188-blue?logo=Jetpack+Compose&amp;logoColor=white" alt="As Seen In - jetc.dev Newsletter Issue #188"></a>
1212

@@ -201,7 +201,7 @@ For a working [sample](sample) open `iosApp/Gradient.xcodeproj` in Xcode and run
201201

202202
You'll find three different use cases:
203203
- `GradientScreenCompose`: A screen rendered entirely in Compose with its state controlled by iOS;
204-
- `GradientScreenMixed`: A screen rendered in Compose with a Swift UIViewController embedded in it;
204+
- `GradientScreenMixed`: A screen rendered in Compose with a SwiftUI View embedded in it;
205205
- `GradientScreenSwift`: A screen rendered entirely in Swift and embedded in Compose.
206206

207207
You can also find other working samples in:

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ buildscript {
1515

1616
allprojects {
1717
group = "com.github.guilhe.kmp"
18-
version = "2.3.0-1.10.0-rc02-5"
18+
version = "2.3.0-1.10.0-rc02-6"
1919
}
2020

2121
dependencies {

kmp-composeuiviewcontroller-gradle-plugin/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ dependencies {
2727
testImplementation(libs.test.kotlin)
2828
}
2929

30-
version = "2.3.0-1.10.0-rc02-5"
30+
version = "2.3.0-1.10.0-rc02-6"
3131
group = "io.github.guilhe.kmp"
3232

3333
gradlePlugin {

kmp-composeuiviewcontroller-gradle-plugin/src/main/kotlin/com/github/guilhe/kmp/composeuiviewcontroller/gradle/KmpComposeUIViewControllerPlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public class KmpComposeUIViewControllerPlugin : Plugin<Project> {
313313
listOf(iosAppFolderName, iosAppName, targetName, autoExport, exportFolderName)
314314

315315
internal companion object {
316-
private const val VERSION_LIBRARY = "2.3.0-1.10.0-rc02-5"
316+
private const val VERSION_LIBRARY = "2.3.0-1.10.0-rc02-6"
317317
private const val LOG_TAG = "KmpComposeUIViewControllerPlugin"
318318
internal const val PLUGIN_KMP = "org.jetbrains.kotlin.multiplatform"
319319
internal const val PLUGIN_KSP = "com.google.devtools.ksp"

kmp-composeuiviewcontroller-ksp/src/main/kotlin/com/github/guilhe/kmp/composeuiviewcontroller/ksp/Processor.kt

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import com.google.devtools.ksp.processing.SymbolProcessor
1414
import com.google.devtools.ksp.processing.SymbolProcessorEnvironment
1515
import com.google.devtools.ksp.processing.SymbolProcessorProvider
1616
import com.google.devtools.ksp.symbol.KSAnnotated
17+
import com.google.devtools.ksp.symbol.KSAnnotation
1718
import com.google.devtools.ksp.symbol.KSFunctionDeclaration
1819
import com.google.devtools.ksp.symbol.KSValueParameter
1920
import kotlinx.serialization.json.Json
@@ -73,11 +74,11 @@ internal class Processor(
7374
}
7475

7576
val frameworkBaseNames = if (swiftExportEnabled) {
76-
getFrameworkBaseNames(composable, node, makeParameters, parameters, modulesMetadata, stateParameter)
77+
getFrameworkBaseNames(composable, makeParameters, parameters, modulesMetadata, stateParameter)
7778
} else {
78-
listOf(trimFrameworkBaseNames(node, modulesMetadata, packageName))
79+
listOf(trimFrameworkBaseNames(composable, modulesMetadata, packageName))
7980
}
80-
val opaqueConfiguration = getOpaqueConfigurationFromAnnotation(node)
81+
val opaqueConfiguration = getOpaqueConfigurationFromAnnotation(composable.annotations)
8182

8283
if (stateParameter == null) {
8384
createKotlinFileWithoutState(packageName, externalImports, composable, makeParameters, parameters, opaqueConfiguration).also {
@@ -95,7 +96,14 @@ internal class Processor(
9596
} else {
9697
val stateParameterName = stateParameter.name()
9798
createKotlinFileWithState(
98-
packageName, externalImports, composable, stateParameterName, stateParameter, makeParameters, parameters, opaqueConfiguration
99+
packageName,
100+
externalImports,
101+
composable,
102+
stateParameterName,
103+
stateParameter,
104+
makeParameters,
105+
parameters,
106+
opaqueConfiguration
99107
).also {
100108
logger.info("${composable.name()}UIViewController created!")
101109
}
@@ -216,28 +224,27 @@ internal class Processor(
216224
.toMap()
217225
}
218226

219-
private fun trimFrameworkBaseNames(node: KSAnnotated, moduleMetadata: List<ModuleMetadata>, packageName: String): String {
227+
private fun trimFrameworkBaseNames(composable: KSFunctionDeclaration, moduleMetadata: List<ModuleMetadata>, packageName: String): String {
220228
val framework = moduleMetadata.firstOrNull { it.packageNames.any { p -> p.startsWith(packageName) } }?.frameworkBaseName ?: ""
221-
framework.ifEmpty { return getFrameworkBaseNameFromAnnotation(node) ?: throw EmptyFrameworkBaseNameException() }
229+
framework.ifEmpty { return getFrameworkBaseNameFromAnnotation(composable.annotations) ?: throw EmptyFrameworkBaseNameException() }
222230
return framework
223231
}
224232

225233
private fun getFrameworkBaseNames(
226234
composable: KSFunctionDeclaration,
227-
node: KSAnnotated,
228235
makeParameters: List<KSValueParameter>,
229236
parameters: List<KSValueParameter>,
230237
modulesMetadata: List<ModuleMetadata>,
231238
stateParameter: KSValueParameter? = null
232239
): List<String> {
233240
return extractFrameworkBaseNames(composable, modulesMetadata, makeParameters, parameters, stateParameter)
234241
.filter { it.isNotBlank() }
235-
.ifEmpty { listOfNotNull(getFrameworkBaseNameFromAnnotation(node)) }
242+
.ifEmpty { listOfNotNull(getFrameworkBaseNameFromAnnotation(composable.annotations)) }
236243
.ifEmpty { throw EmptyFrameworkBaseNameException() }
237244
}
238245

239-
private fun getFrameworkBaseNameFromAnnotation(node: KSAnnotated): String? {
240-
val annotation = node.annotations.firstOrNull { it.shortName.asString() == composeUIViewControllerAnnotationName.name() }
246+
private fun getFrameworkBaseNameFromAnnotation(annotations: Sequence<KSAnnotation>): String? {
247+
val annotation = annotations.firstOrNull { it.shortName.asString() == composeUIViewControllerAnnotationName.name() }
241248
if (annotation != null) {
242249
val argument = annotation.arguments.firstOrNull { it.name?.asString() == frameworkBaseNameAnnotationParameter }
243250
if (argument != null) {
@@ -250,8 +257,8 @@ internal class Processor(
250257
return null
251258
}
252259

253-
private fun getOpaqueConfigurationFromAnnotation(node: KSAnnotated): Boolean {
254-
val annotation = node.annotations.firstOrNull { it.shortName.asString() == composeUIViewControllerAnnotationName.name() }
260+
private fun getOpaqueConfigurationFromAnnotation(annotations: Sequence<KSAnnotation>): Boolean {
261+
val annotation = annotations.firstOrNull { it.shortName.asString() == composeUIViewControllerAnnotationName.name() }
255262
if (annotation != null) {
256263
val argument = annotation.arguments.firstOrNull { it.name?.asString() == composeUIViewControllerOpaqueConfiguration }
257264
if (argument != null) {

sample/gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[versions]
22
kotlin = "2.3.0"
3-
composeMultiplatform = "1.11.0-alpha01"
3+
composeMultiplatform = "1.10.0-rc02"
44

55
composeMaterial3 = "1.9.0"
66
kotlinxCollections = "0.4.0"

0 commit comments

Comments
 (0)