RedMadRobot / figma-export

Command line utility to export colors, typography, icons and images from Figma to Xcode / Android Studio project
MIT License
726 stars 114 forks source link

keyNotFound(CodingKeys(stringValue: "nameStyle", intValue: nil) #81

Closed davidaberg closed 3 years ago

davidaberg commented 3 years ago

Not sure what goes wrong here. I modified the yaml file from the SwiftUI example app with my own file Id. When I run figma-export colors -i figma-export.yaml I then get this error:

Error: keyNotFound(CodingKeys(stringValue: "nameStyle", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "ios", intValue: nil), CodingKeys(stringValue: "colors", intValue: nil)], debugDescription: "No value associated with key CodingKeys(stringValue: \"nameStyle\", intValue: nil) (\"nameStyle\").", underlyingError: nil))

I tried a couple of different Figma files and got the same error.

figma:
  lightFileId: XXX

# [optional] Common export parameters
common:
  colors:
    # RegExp pattern for color name validation before exporting
    nameValidateRegexp: '^[a-zA-Z_]+$' # RegExp pattern for: background, background_primary, widget_primary_background
  icons:
    # RegExp pattern for icon name validation before exporting
    nameValidateRegexp: '^(ic)_(\d\d)_([a-z0-9_]+)$' # RegExp pattern for: ic_24_icon_name, ic_24_icon
  images:
    # RegExp pattern for image name validation before exporting
    nameValidateRegexp: '^(img)_([a-z0-9_]+)$' # RegExp pattern for: img_image_name

# [optional] iOS export parameters
ios:
  # Path to xcodeproj
  xcodeprojPath: "./TestFigma.xcodeproj"
  # Xcode Target containing resources and corresponding swift code
  target: "TestFigma"
  # Path to the Assets.xcassets directory
  xcassetsPath: "./TestFigma/Assets.xcassets"
  # Is Assets.xcassets located in the main bundle?
  xcassetsInMainBundle: true

  # Parameters for exporting colors
  colors:
    # Should be generate color assets instead of pure swift code
    useColorAssets: True
    # Name of the folder inside Assets.xcassets where to place colors (.colorset directories)
    assetsFolder: Colors
    # Color name style: camelCase or snake_case
    nameStyle: camelCase
    # [optional] Absolute or relative path to swift file where to export UIKit colors (UIColor) for accessing from the code (e.g. UIColor.backgroundPrimary)
    colorSwift: "./TestFigma/View/Common/UIColor+extension.swift"
    # [optional] Absolute or relative path to swift file where to export SwiftUI colors (Color) for accessing from the code (e.g. Color.backgroundPrimary)
    swiftuiColorSwift: "./TestFigma/View/Common/Color+extension.swift"

  # Parameters for exporting icons
  icons:
    # Image file format: pdf or svg
    format: svg
    # Name of the folder inside Assets.xcassets where to place icons (.imageset directories)
    assetsFolder: Icons
    # Icon name style: camelCase or snake_case
    nameStyle: camelCase
    # [optional] Absolute or relative path to swift file where to export icons (SwiftUI’s Image) for accessing from the code (e.g. Image.illZeroNoInternet)
    swiftUIImageSwift: "./TestFigma/View/Common/Image+extension_icons.swift"

  # Parameters for exporting images
  images:
    # Name of the folder inside Assets.xcassets where to place images (.imageset directories)
    assetsFolder: Illustrations
    # Image name style: camelCase or snake_case
    nameStyle: camelCase
    # [optional] Absolute or relative path to swift file where to export images (SwiftUI’s Image) for accessing from the code (e.g. Image.illZeroNoInternet)
    swiftUIImageSwift: "./TestFigma/View/Common/Image+extension_illustrations.swift"

  # Parameters for exporting typography
  typography:
    # [optional] Absolute or relative path to swift file where to export UIKit fonts (UIFont extension).
    fontSwift: "./TestFigma/View/Common/UIFont+extension.swift"
    # [optional] Absolute or relative path to swift file where to export SwiftUI fonts (Font extension).
    swiftUIFontSwift: "./TestFigma/View/Common/Font+extension.swift"

    # Will FigmaExport generate UILabel for each text style (font) e.g. HeaderLabel, BodyLabel, CaptionLabel.
    generateLabels: false
subdan commented 3 years ago

Hello. I've found an issue. typography section must contains nameStyle parameter. Just add nameStyle: camelCase parameter to the typography section.

subdan commented 3 years ago

I've just updated config file for ExampleSwiftUI. https://github.com/RedMadRobot/figma-export/blob/master/Examples/ExampleSwiftUI/figma-export.yaml

davidaberg commented 3 years ago

That did it, thanks!

ptxmac commented 2 years ago

It looks like the figma-export init command is still creating a invalid sample config