Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Config] CLI Compose Android Figma Connect #211

Open
ViktoriiaYarska opened this issue Nov 15, 2024 · 1 comment
Open

[Config] CLI Compose Android Figma Connect #211

ViktoriiaYarska opened this issue Nov 15, 2024 · 1 comment

Comments

@ViktoriiaYarska
Copy link

ViktoriiaYarska commented Nov 15, 2024

Thanks for adding support of the Android Compose 🚀

Would you consider adding a connected app example to the documentation for easier integration? Also, It is missing the CLI part on the Compose page

Env

  • Code Connect CLI version : 1.2.2
  • Operating system: Mac OS
  • Code Connect file:
{
  "codeConnect": {
    "parser": "compose",
    "include": [
      "design/src/main/java/com/example/android/design/compose/component/**"
    ],
  }
}

CLI command

npx figma connect publish --token <token> --verbose

Error

Config file found, parsing /<project-path> using specified include globs
Running parser: ./gradlew -p . parseCodeConnect -PfilePath=tmp/figma-code-connect-parser-io.json.tmp -q

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':design:parseCodeConnect'.
> Could not initialize class com.figma.code.connect.models.FigmaString

On the same config file & untouched code, I could receive sometimes another error:

Config file found, parsing  /<project-path> using specified include globs
Running parser: ./gradlew -p . parseCodeConnect -PfilePath=tmp/figma-code-connect-parser-io.json.tmp -q
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':design:parseCodeConnect'.
> 'kotlinx.serialization.KSerializer kotlinx.serialization.internal.EnumsKt.createAnnotatedEnumSerializer(java.lang.String, java.lang.Enum[], java.lang.String[], java.lang.annotation.Annotation[][], java.lang.annotation.Annotation[])'

I tried adding "gradleWrapperPath": ".." and removing "parser": "compose", - receiving same error

Could you please help locate the issue or add an app example with proper configuration?

@rgullyfigma
Copy link

rgullyfigma commented Feb 21, 2025

Hi @ViktoriiaYarska, sorry for the delayed response. I haven't been able to reproduce this issue on my end so far.

This is what my setup looks like:

ButtonDoc.kt

@FigmaConnect(url="https://www.figma.com/design/.../...?node-id=0-5&t=...")
class ButtonDoc {

    @FigmaProperty(FigmaType.Text, "label")
    val label = "Click me"

    @FigmaProperty(FigmaType.Boolean, "disabled", true)
    val disabled: Boolean? = null

    @FigmaProperty(FigmaType.Enum, "variant")
    val variant: ButtonVariant = Figma.mapping(
        "default" to ButtonVariant.Default,
        "large" to ButtonVariant.Large
    )

    @Composable
    fun Component() {
        Button(
            variant = variant,
            label = label,
            disabled = disabled
        )
    }
}

libs.versions.toml

[versions]
kotlin = "2.0.0"
codeConnectLib = "1.1.3"
...

[libraries]
code-connect-lib = { module = "com.figma.code.connect:code-connect-lib", version.ref = "codeConnectLib" }
...

build.gradle.kts

plugins {
    id("com.figma.code.connect") version "1.2.1"
    ...
}

dependencies {
    implementation(libs.code.connect.lib)
    ...
}

Are you able to provide a sample of a @FigmaConnect file that you're trying to connect, your Kotlin version, and Code Connect Lib version to help debug?

It also may be worth updating to the latest Code Connect CLI version 1.3.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants