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

Unhandled error event when using Figma connect #226

Open
thomtreebus opened this issue Dec 17, 2024 · 1 comment
Open

Unhandled error event when using Figma connect #226

thomtreebus opened this issue Dec 17, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@thomtreebus
Copy link

I'm trying to use the interactive setup to connect my design system to code connect. When asked for the URL of the Figma file with my design system library (step 3 in the guide), I get this error:

node:events:497
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (node:internal/streams/destroy:169:8)
    at emitErrorCloseNT (node:internal/streams/destroy:128:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
}

Node.js v21.7.1

I tried running swift run -c release --verbose figma-swift, which produced the following error:

error: binary operator '??' cannot be applied to operands of type '(output: String, changes: [Formatter.Change])?' and 'String'
225 | 
226 |     private func rewriteCodeBlockWithTemplate() -> String {
227 |         let formatted = (try? SwiftFormat.format(code.trimmedDescriptionRemovingReturnStatement())) ?? code.trimmedDescriptionRemovingReturnStatement()
    |                                                                                                     `- error: binary operator '??' cannot be applied to operands of type '(output: String, changes: [Formatter.Change])?' and 'String'
228 |         let tree = Parser.parse(source: formatted)
229 |         let rewriter = MappedPropertyRewriter(

path/to/project/.build/checkouts/code-connect/swiftui/lib/CodeConnectTemplateWriter.swift:249:35: error: cannot infer contextual base in reference to member 'whitespacesAndNewlines'
247 |         ).replaceNestedInstancePlaceholders(
248 |             nestedInstanceCalls: rewriter.nestedInstanceCalls
249 |         ).trimmingCharacters(in: .whitespacesAndNewlines)
    |                                   `- error: cannot infer contextual base in reference to member 'whitespacesAndNewlines'
250 |         
251 |         return "export default figma.swift`\(rewrittenCode)`"
  • Code Connect CLI version: 1.1.2
  • Operating system: OSX

figma.config for my SwiftUI project:

{
  "codeConnect": {
    "swiftPackagePath": "Package.swift",
    "include": ["Sources/**/**/*"],
    "exclude": ["markdown/**", "danger/**", "scripts/**", "SnapshotTests/**"]
  }
}

My Package.swift setup:

import PackageDescription

let package = Package(
    name: "ProjectName",
    defaultLocalization: "en",
    platforms: [
        .macOS(.v14),
        .iOS(.v16)
    ],
    products: [
        .library(name: "ProjectName", targets: ["ProjectTarget"])
    ],
    dependencies: [
        ...
        .package(url: "https://github.com/figma/code-connect", from: "1.0.0"),
    ],
    targets: [
        .target(name: "ProjectTarget",
            dependencies: [
                ...
                .product(name: "Figma", package: "code-connect")
            ],
            path: "Path/To/Project"
        )
    ]
)
@slees-figma slees-figma added bug Something isn't working and removed API question labels Dec 18, 2024
@slees-figma
Copy link

Hi @thomtreebus, thanks for the report! We've identified the issue and working on a fix.

In the meantime if you can force the version for SwiftFormat of 0.53.5 in your project that should fix the issue in the meantime. Sorry for the inconvenience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants