Git Product home page Git Product logo

figma-export's Introduction

FigmaExport


SPM compatible GitHub license CocoaPods Compatible codebeat badge Test

Command line utility to export colors, typography, icons and images from Figma to Xcode / Android Studio project.

  • color - Figma's color style
  • typography - Figma's text style
  • icon — Figma's component with small black/colorized vector image
  • image — Figma's components with colorized image (Light/Dark)

The utility supports Dark Mode, SwiftUI and Jetpack Compose.

Why we've developed this utility:

  • Figma doesn't support exporting colors and images to Xcode / Android Studio. Manual export takes a long time.
  • For easy sync of the component library with the code

Articles:

Table of Contents:

Features

  • Export light & dark color palette directly to Xcode / Android studio project
  • Export icons to Xcode / Android Studio project
  • Export images to Xcode / Android Studio project
  • Export text styles to Xcode / Android Studio project
  • Supports Dark Mode
  • Supports High contrast colors for Xcode
  • Supports SwiftUI and UIKit
  • Supports Objective-C
  • Supports RTL

Exporting icons and images works only for Professional/Organisation Figma plan because FigmaExport use Shareable team libraries.

Result

iOS

Colors

When your execute figma-export colors command, figma-export exports colors from Figma directly to your Xcode project to the Assets.xcassets folder.

Figma light Figma dark Xcode

Additionally, the following Swift file will be created to use colors from the code.

 import UIKit
 
 extension UIColor {
    static var backgroundSecondaryError: UIColor { return UIColor(named: #function)! }
    static var backgroundSecondarySuccess: UIColor { return UIColor(named: #function)! }
    static var backgroundVideo: UIColor { return UIColor(named: #function)! }
    ...
 }

For SwiftUI the following Swift file will be created to use colors from the code.

 import SwiftUI
 
 extension Color {
    static var backgroundSecondaryError: Color { return Color(#function) }
    static var backgroundSecondarySuccess: Color { return Color(#function) }
    static var backgroundVideo: Color { return Color(#function) }
    ...
 }

If you set option useColorAssets: False in the configuration file, then will be generated code like this:

UIKit:

import UIKit

extension UIColor {
    static var primaryText: UIColor {
        if #available(iOS 13.0, *) {
            return UIColor { traitCollection -> UIColor in
                if traitCollection.userInterfaceStyle == .dark {
                    return UIColor(red: 0.000, green: 0.000, blue: 0.000, alpha: 1.000)
                } else {
                    return UIColor(red: 1.000, green: 1.000, blue: 1.000, alpha: 1.000)
                }
            }
        } else {
            return UIColor(red: 1.000, green: 1.000, blue: 1.000, alpha: 1.000)
        }
    }
    static var backgroundVideo: UIColor {
        return UIColor(red: 0.467, green: 0.012, blue: 1.000, alpha: 0.500)
    }
}

SwiftUI:

import SwiftUI

public extension ShapeStyle where Self == Color {
    static var primaryText: Color { Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) }
}

Icons

Icons will be exported as PDF or SVG files with Template Image render mode.

Additionally, the following Swift file will be created to use icons from the code.

import UIKit

extension UIImage {
    static var ic16Notification: UIImage { return UIImage(named: #function)! }
    static var ic24ArrowRight: UIImage { return UIImage(named: #function)! }
    static var ic24Close: UIImage { return UIImage(named: #function)! }
    static var ic24Dots: UIImage { return UIImage(named: #function)! }
    ...
}

For SwiftUI the following Swift file will be created to use images from the code.

import SwiftUI

extension Image {
    static var ic16Notification: Image { return Image(#function) }
    static var ic24Close: Image { return Image(#function) }
    static var ic24DropdownDown: Image { return Image(#function) }
    static var ic24DropdownUp: Image { return Image(#function) }
    ...
}
...
VStack {
  Image.ic24Close
  Image.ic24DropdownDown
}
...

Images

Images will be exported as PNG files the same way.

Additionally, the following Swift file will be created to use images from the code.

import UIKit

extension UIImage {
    static var illZeroEmpty: UIImage { return UIImage(named: #function)! }
    static var illZeroNetworkError: UIImage { return UIImage(named: #function)! }
    static var illZeroServerError: UIImage { return UIImage(named: #function)! }
    ...
}

For SwiftUI a Swift file will be created to use images from the code.

Images with multiple idiom

If name of an image contains idiom at the end (e.g. ~ipad), it will be exported like this:

Typography

When your execute figma-export typography command figma-export generates 3 files:

  1. UIFont+extension.swift extension for UIFont that declares your custom fonts. Use these fonts like this UIFont.header(), UIFont.caption1().
  2. LabelStyle.swift struct for generating attributes for NSAttributesString with custom lineHeight and tracking (letter spacing).
  3. Label.swift file that contains base Label class and class for each text style. E.g. HeaderLabel, BodyLabel, Caption1Label. Specify these classes in xib files on in code.

Example of these files:

Android

Colors will be exported to values/colors.xml and values-night/colors.xml files. For Jetpack Compose, following code will be generated, if configured:

package com.redmadrobot.androidcomposeexample.ui.figmaexport

import ...

object Colors

@Composable
@ReadOnlyComposable
fun Colors.backgroundPrimary(): Color = colorResource(id = R.color.background_primary)

Icons will be exported to drawable directory as vector xml files. For Jetpack Compose, following code will be generated, if configured:

package com.redmadrobot.androidcomposeexample.ui.figmaexport

import ...

object Icons

@Composable
fun Icons.Ic24DropdownDown(
    contentDescription: String?,
    modifier: Modifier = Modifier,
    tint: Color = Color.Unspecified
) {
    Icon(
        painter = painterResource(id = R.drawable.ic_24_dropdown_down),
        contentDescription = contentDescription,
        modifier = modifier,
        tint = tint
    )
}

Vector images will be exported to drawable and drawable-night directories as vector xml files. Raster images will be exported to drawable-???dpi and drawable-night-???dpi directories as png or webp files.

Typography will be exported to values/typography.xml. For Jetpack Compose, following code will be generated, if configured:

package com.redmadrobot.androidcomposeexample.ui.figmaexport

import ...

object Typography {

    val body = TextStyle(
        fontFamily = FontFamily(Font(R.font.ptsans_regular)),
        fontSize = 16.0.sp,
        letterSpacing = 0.0.sp,
        lineHeight = 24.0.sp,
    )
}

Installation

Before installation you must provide Figma personal access token via environment variables.

export FIGMA_PERSONAL_TOKEN=value

This token gives you access to the Figma API. Generate a personal Access Token through your user profile page or on Figma API documentation website. If you use Fastlane just add the following line to fastlane/.env file

FIGMA_PERSONAL_TOKEN=value

Manual

Download the latest release and read Usage

Homebrew

brew install RedMadRobot/formulae/figma-export

If you want to export raster images in WebP format install cwebp command line utility.

brew install webp

CocoaPods + Fastlane

Add the following line to your Podfile:

pod 'FigmaExport'

This will download the FigmaExport binaries and dependencies in Pods/ during your next pod install execution and will allow you to invoke it via Pods/FigmaExport/Release/figma-export in your Fastfile.

Add the following line to your Fastfile:

lane :sync_colors do
  Dir.chdir("../") do
    sh "Pods/FigmaExport/Release/figma-export colors ."
  end
end

Don't forget to place figma-export.yaml file at the root of the project directory.

Run fastlane sync_colors to run FigmaExport.

Usage

  1. Open Terminal.app

  2. Go (cd) to the folder with figma-export binary file

  3. Run figma-export

    To export colors use colors argument:

    ./figma-export colors -i figma-export.yaml

    To export icons use icons argument:

    ./figma-export icons -i figma-export.yaml

    To export images use images argument:

    ./figma-export images -i figma-export.yaml

    To export typography use typography argument:

    ./figma-export typography -i figma-export.yaml

Android

In the figma-export.yaml file you must specify the following properties:

  • android.mainRes
  • android.resourcePackage if you want to generate Jetpack Compose code
  • android.mainSrc if you want to generate Jetpack Compose code
  • android.icons.output if you want to export icons
  • android.images.output if you want to export images

When you execute figma-export icons command, FigmaExport clears the {android.mainRes}/{android.icons.output} directory before exporting all the icons.

When you execute figma-export images command, FigmaExport clears the {android.mainRes}/{android.images.output} directory before exporting all the images.

Example folder structure:

main/
  res/
    figma-export-icons/
      drawable/
      drawable-night/
    figma-export-images/
      drawable/
      drawable-night/

Before first running figma-export you must add path to these directories in the app‘s build.gradle file.

...
android {
  ...
  sourceSets {
    main {
      res.srcDirs += "src/main/res/figma-export-icons"
      res.srcDirs += "src/main/res/figma-export-images"
    }
  }
}

Jetpack Compose

For Typography, Colors and Icons you can enable code generation for the use with Jetpack Compose in your config file:

  1. Configure android.mainSrc
  2. Configure android.[typography|colors|icons].composePackageName

Arguments

If you want to export specific colors/icons/images you can list their names in the last argument like this:

./figma-export icons "ic/24/edit" — Exports only one icon.

./figma-export icons "ic/24/edit, ic/16/notification" — Exports two icons

./figma-export icons "ic/24/videoplayer/*" — Exports all icons which names starts with ic/24/videoplayer/

./figma-export colors "common/*" — Exports all the colors which names starts with common

./figma-export colors — Exports all the colors.

⚠️ Wildcard doesn't work on Linux.

Argument -i or -input specifies path to FigmaExport configuration file figma-export.yaml.

Configuration

All available configuration options described in the CONFIG.md file.

Example of figma-export.yaml file for iOS project — Examples/Example/figma-export.yaml

Example of figma-export.yaml file for Android project — Examples/AndroidExample/figma-export.yaml

Generate figma-export.yaml config file using one of the following command:

figma-export init --platform android
figma-export init --platform ios

It will generate config file in the current directory.

Custom templates

FigmaExport uses Stencil and StencilSwiftKit to generate code.

iOS

If you want to modify structure of the generated *.swift files you should specify a directory (ios.templatesPath) where Stencil templates are located. If ios.templatesPath not specified default templates will be used.

Default Stencil templates for iOS located here: ./Sources/XcodeExport/Resources Custom Stencil templates for colors and images must have the following names:

  • UIColor+extension.swift.stencil for UIKit colors
  • Color+extension.swift.stencil for SwiftUI colors
  • UIImage+extension.swift.stencil for UIKit images
  • Image+extension.swift.stencil for SwiftUI images

Custom Stencil templates for typography must have the following names:

  • Label.swift.stencil,
  • LabelStyle.swift.stencil,
  • LabelStyle+extension.swift.stencil,
  • UIFont+extension.swift.stencil
  • Font+extension.swift.stencil.stencil
Android

If you want to modify structure of the generated .xml, .kt files you should specify a directory (android.templatesPath) where Stencil templates are located. If android.templatesPath not specified default templates will be used.

Defaul Stencil templates for Android located here: ./Sources/AndroidExport/Resources Custom Stencil templates must have the following names:

  • colors.xml.stencil
  • Colors.kt.stencil
  • Icons.kt.stencil
  • typography.xml.stencil
  • Typography.kt.stencil

Exporting Typography

iOS

  1. Add a custom font to the Xcode project. Drag & drop font file to the Xcode project, set target membership, and add font file name in the Info.plist file. See developer documentation for more info.
  2. Run figma-export typography to export text styles
  3. Use generated fonts and labels in your code. E.g. button.titleLabel?.font = UIFont.body(), let label = HeaderLabel().

Android

  1. Place font file under the res directory of your module
  2. Run figma-export typography to export text styles
  3. Create a top level style as a parent for the generated styles. For example:
<style name="FigmaExport.TextAppearance" parent="Widget.AppCompat">
</style>
  1. Use the generated styles in your code

Design requirements

If a color, icon or image is unique for iOS or Android platform, it should contains "ios" or "android" word in the description field in the properties. If a color, icon or image is used only by the designer, and it should not be exported, the word "none" should be specified in the description field.

If an icon supports RTL, it should contains "rtl" word in the description field in the properties.

Styles and Components must be published to a Team Library.

For colors

For figma-export colors

By default, if you support dark mode your Figma project must contains two files. One should contains a dark color palette, and the another light color palette. If you would like to specify light and dark colors in the same file, you can do so with the useSingleFile configuration option. You can then denote dark mode colors by adding a suffix like _dark. The suffix is also configurable. See CONFIG.md for more information in the colors section.

If you support high contrast mode without dark mode your Figma project must contains two files. One should contains a high contrast color palette, and the another light color palette. If you would like to specify light and high contrast colors in the same file, you can do so with the useSingleFile configuration option. You can then denote high contrast mode colors by adding a suffix like _lightHC. The suffix is also configurable. See CONFIG.md for more information in the colors section.

If you support high contrast mode with dark mode your Figma project must contains four files. Should be like this: light, dark, high contrast light, high contrast dark. If you would like to specify colors in the same file, you can do so with the useSingleFile configuration option. You can then denote high contrast mode colors by adding a suffix like _lightHC for light and _darkHC for dark high contrast colors. The suffix is also configurable. See CONFIG.md for more information in the colors section.

The light color palette may contain more colors than the dark or high light color palette wherein the dark color palette may contain more colors than the high dark color palette. If a light-only color is present, it will be considered as universal color for the iOS color palette. Names of the dark, high light and high dark colors must match the light colors.

Example

File Styles

For variables

For figma-export colors

Important, the API for working with color variables in Figma is still in Beta stage, so something may break at any time.

Important, in figma-export.yaml use either colors or variablesColors.

With the introduction of color variables in Figma, you can use it instead of color styles. Color variables can be used in figma-export, for this in figma-export.yaml you need to use the variablesColors option instead of colors.

The value of variables can be either the final color value or another variable. For example, the Primary variable can contain the value #FFFFFF, and the Secondary variable can contain the value Pand/90. Figma-export can work with any depth of variable nesting. You can specify the primitivesModeName parameter to indicate the mode for the final table with your primitives, if the parameter is not specified, the default value will be used.

Example:

  1. tokensCollectionName - the name of the variable collection
  2. lightModeName - the name of the color variable column for the light theme
  3. darkModeName - the name of the color variable column for the dark theme
  4. lightHCModeName - the name of the color variable column for the light theme with high contrast
  5. darkHCModeName - the name of the color variable column for the dark theme with high contrast
  6. A variable that has a local value
  7. A variable that refers to another variable in a different file

  1. primitivesModeName - the name of the variable column, if the value in figma-export.yaml is not specified, the default value will be used
  2. A variable that has a local value

See CONFIG.md for more information in the variablesColors section.

For icons

For figma-export icons

By default, your Figma file should contains a frame with Icons name which contains components for each icon. You may change a frame name in a CONFIG.md file by setting common.icons.figmaFrameName property. If you support dark mode and want separate icons for dark mode, Figma project must contains two files. One should contains a dark icons, and another light icons. If you would like to have light and dark icons in the same file, you can do so with the useSingleFile configuration option. You can then denote dark mode icons by adding a suffix like _dark. The suffix is also configurable. See CONFIG.md for more information in the icons section.

For images

For figma-export images

Your Figma file should contains a frame with Illustrations name which contains components for each illustration. You may change a frame name in a CONFIG.md file by setting common.images.figmaFrameName property.

If you support dark mode you must have two Figma files. The rules for these two files follow the same rules as described above for colors. But If you would like to specify light and dark illustrations in the same file, you can do so with the useSingleFile configuration option. You can then denote dark mode illustrations by adding a suffix like _dark. The suffix is also configurable. See CONFIG.md for more information in the illustrations section.

If you want to specify image variants for different devices (iPhone, iPad, Mac etc.), add an extra ~ mark with idiom name. For example add ~ipad postfix:

For typography

For figma-export typography.

Your Figma file must contains Text Styles.

Dynamic Type

It is recommended to support Dynamic Type. Dynamic Type provides additional flexibility by letting readers choose their preferred text size.

If you want to support Dynamic Type you should specify iOS native text style for your custom text styles in the description field of Text Style. Available iOS native text styles you can find on Human Interface Guidlines page in Typography/Dynamic Type Sizes.

For example: You have header text style with 20 pt font size. Native iOS text style that matches is "Title 3". In the description field of your header text style you should specify "Title 3".

Advice: Font in Tab Bar and standard Navigation Bar must not support Dynamic Type.

Example project

Example iOS projects, Android projects and example Figma files see in the Examples folder

Contributing

We'd love to accept your pull requests to this project.

License

figma-export is released under the MIT license. See LICENSE for details.

Feedback

If you have any issues with the FigmaExport or you want some new features feel free to create an issue, open a discussion or contact me.

Authors

Daniil Subbotin - [email protected]

figma-export's People

Contributors

alexander-ignition avatar alexey1312 avatar alldmeat avatar alldne avatar andreyoshev avatar dependabot[bot] avatar devfirts avatar edvaldeysteinsson avatar farkasseb avatar ichikmarev avatar iljakosynkin avatar jonlz avatar kaiwidmer avatar lichin-lin avatar modestman avatar niusounds avatar nofearjoe avatar ptxmac avatar remenkoff avatar rlinoz avatar sergeirr avatar simonlee2 avatar subdan avatar tatsuz0u avatar ttoxa-xa avatar tujh2 avatar vani2 avatar y-okudera avatar yyjim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

figma-export's Issues

Images not loading due to request timeout

We have about 120 images and when we try to export them the request fails due to timeout.
We tried to change the timeout in FigmaClient to 600, but got this error: Unexpectedly found nil while implicitly unwrapping an Optional value: file FigmaAPI/FigmaClient.swift, line 26.

We are using the latest version of figma-export (0.18.5).

Custom filenames pattern

It would be great to have the possibility to customize the filenames pattern.
It can be done with capture group references. Something like:

common:
  icons:
    nameRegex: '^(\d\d) \\ ([A-Za-z0-9 ]+)$'
    filename: 'icon_$2_$1'

32 \ Profile -> icon_profile_32

Crash when image contains cyrillic characters in name

$ figma-export images "АБВГД"
2020-11-27T09:19:02+0300 info: Using FigmaExport to export images to Android Studio project.
2020-11-27T09:19:02+0300 info: Fetching images info from Figma. Please wait...
2020-11-27T09:19:06+0300 info: Processing images...
2020-11-27T09:19:06+0300 info: Downloading remote files...
fish: 'figma-export images "…' terminated by signal SIGILL (Illegal instruction)

I think figma-export should throw an exception instead of a silent crash

Color style contain number let export color command failed

for style value like red/a80, red/a60 will make figma-export colors -i command failed, example as follow:

Figma File and Docs

You can take a look for the file here
Figma File Link

Error log

截圖 2021-02-25 上午10 05 08

Expected result

Command should work as usual, maybe let the value become:
gray, red, reda80, reda60 or gray, red, redA80, redA60 or gray, red, red_a80, red_a60

Error after SVG export

This error occurs after the export of any SVG. I've not tested it for WEBP

2020-11-27T09:13:21+0300 info: Using FigmaExport to export images to Android Studio project.
2020-11-27T09:13:21+0300 info: Fetching images info from Figma. Please wait...
2020-11-27T09:13:25+0300 info: Processing images...
2020-11-27T09:13:25+0300 info: Downloading remote files...
2020-11-27T09:13:26+0300 info: Downloaded 1/1
2020-11-27T09:13:26+0300 info: Converting SVGs to XMLs...
-c parsed, so we will convert the SVG files
-in parsed /var/folders/3c/nnj_p6v93bg7pgs4dkm6cgzc0000gp/T/596D7CCE-4712-4980-9691-7AEC3B68B944
Convert 1 SVG files in total, errors found in 0 files
2020-11-27T09:13:31+0300 info: Writting files to Android Studio project...
Error: Error Domain=NSCocoaErrorDomain Code=4 "“76A43668-8283-4F87-935F-849B32DD57D7” couldn’t be removed." UserInfo={NSUserStringVariant=(
    Remove
), NSFilePath=/var/folders/3c/nnj_p6v93bg7pgs4dkm6cgzc0000gp/T/76A43668-8283-4F87-935F-849B32DD57D7, NSUnderlyingError=0x7fc9e191f630 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

Support exporting from a single figma file

Thank you for the great library. This is a tool I am exploring using however my design team has a requirement to only maintain the color styles for both the light and dark color palette in a single figma file. I see that right now you only support a separate file for light and dark styles. Is this something you would entertain? I would be happy to help build out the feature if so.

I took an initial pass at it, and was able to prototype it out by modifying the ColorsLoader. If we add an export option, update the documentation, and configure the loader to be able to make this modification it should work. What do you think?

func load() throws -> (light: [Color], dark: [Color]?) {
        let colors = try loadColors(fileId: params.lightFileId)
        let darkSuffix = "_dark"
        let lightColors = colors
            .filter { !$0.name.hasSuffix(darkSuffix)}
        let darkColors = colors
            .filter { $0.name.hasSuffix(darkSuffix) }
            .map { color -> Color in
                var newColor = color
                newColor.name = String(color.name.dropLast(darkSuffix.count))
                return newColor
            }
        return (lightColors, darkColors)
    }

Output progress when fetching image URLs

Fetching URLs for images using Figma API takes a long time. FigmaExport should output progress to the console.

Example:

> Fetching images info from Figma. Please wait...
> Fetching in progress 0/100
> Fetching in progress 20/100
> Fetching in progress 40/100

Add support for iPad idiom when exporting images / icons

🚀 Feature request

Sometime, Designer might want to have a different kind of image show up for iPad platform compare to iPhone platform
for example: different size / different color or shape...etc

will it be possible to support this feature for iOS, so the developer can see something like this (idiom shows either iphone or ipad instead of universal):

截圖 2020-10-20 上午11 05 04

💡 Possible solution

To achieve the feature, we can use some kind of naming convention, I suggest that we can make designer control the idioms by using the ~ tilde symbol:

截圖 2020-10-20 上午11 08 36

as the image shows, we can combine them into same imageset when parsing, and note different idiom in content.json.

with this tilde naming convention, I think there will be more flexibility for image / icons to show up for different platform.

Fonts figma export for android studio

Icons must be exported to font directory (the same root level as drawable directory) as ttf files. Names must have snake case style. One font ttf file for each font style. Example in the image below.
Screenshot 2020-11-24 at 12 01 36

Use wildcard on export

It would be great to be able to export icons or illustrations matching wildcard:

figma-export images "200x200/*" # Export all illustrations 200x200
figma-export icons "32/navigation/*" # Export all navigation icons

Add SwiftUI support

Color.backgroundPrimary
Color.buttonPressed

Text("Hello World!").style(.header)
Text("Hello World!").style(.caption1)

Support for Universal Colors

I was curious about the validation that ensures there is a corresponding dark mode color for every light mode color. In some cases, a design system might only have a single color that is used across both the light and dark color palette.

Consider something like this:
image

What do you think about adding a configuration option to opt out of that warning? Then the xcode exporter step can check if only a light color exists, it turns it into a color set with the None appearances option. This color will then not respond to appearance changes.

Add support for several xcassets and Figma frames

Today extension has its own xcassets file. I would like to be able to specify a frame → xcassets pair (which frame to export to which xcassets).
Example:

ios:
  - xcassetsPath: "/Users/d.subbotin/app_name/Resources/Assets.xcassets"
    images:
      frameName: Illustrations
      assetsFolder: Illustrations
  - xcassetsPath: "/Users/d.subbotin/app_name/Widget/Resources/Assets.xcassets"
    images:
      frameName: Illustrations_widget
      assetsFolder: Illustrations

FigmaExport doesn't delete old resources (Android)

There is a Figma file with 50 icons.
Export the icons to an Android project.
Remove 10 icons from Figma.
Export the icons to the Android project again.
Deleted icons are not deleted from the Android project.

There was an idea to make nested folders inside drawable, for example drawable/icons, but it is prohibited.

Relative file path support

File paths used in this properties

  • ios. xcassetsPath
  • ios. colorSwift
  • android.mainRes

Is relative path supported?

If supported, please update the Readme.md

Failed when export colors

When I export I get this error. What I can do?

Using FigmaExport to export colors.
Fetching colors. Please wait...
Error: keyNotFound(CodingKeys(stringValue: "color", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "nodes", intValue: nil), _JSONKey(stringValue: "95:32", intValue: nil), CodingKeys(stringValue: "document", intValue: nil), CodingKeys(stringValue: "fills", intValue: nil), _JSONKey(stringValue: "Index 1", intValue: 1)], debugDescription: "No value associated with key CodingKeys(stringValue: \"color\", intValue: nil) (\"color\").", underlyingError: nil))

How do you build figma-export from source?

Hello, I have some feature ideas I'd like to play with. I've forked and cloned the repo, but I can't figure out what commands to run to build a local binary.

What is the workflow to make changes and test? Thanks!

Illegal hardware instruction

Hello! Thanks for your awesome utility.

But I have a problem when using with Xcode 12.3 and figma-export 0.18.5. Everything was fine on the previous Xcode version.

❯ figma-export icons -i figma-export.yaml
2020-12-16T19:08:16+0200 info com.redmadrobot.figma-export : Using FigmaExport to export icons to Xcode project.
2020-12-16T19:08:16+0200 info com.redmadrobot.figma-export : Fetching icons info from Figma. Please wait...
2020-12-16T19:08:20+0200 info com.redmadrobot.figma-export : Processing icons...
[1]    97815 illegal hardware instruction  figma-export icons -i figma-export.yaml

Unable to execute commands in powershell

Trying to give the tool a whirl but having issues running the application in the terminal.

  1. I downloaded the latest release today and unzipped the contents to C:\Program Files\FigmaExporter\
  2. Set personal figma token as an env variable
  3. Open powershell in the directory containing figma-export binary and the vd-tools directory
  4. Enter "figma-export init --platform android" to create config
  5. Instead of the config file being created in the directory, the system attempts to 'open' the figma-export binary. No file is created / the binary does not run

Gotta be missing something - any help would be appreciated. thank you!

Show error when a user tries to export an unsupported Color Style

Example. FigmaExport, iOS and Android doesn't support gradient colors.
When a user tries to export this Color Style output:

❌ Error: unable to export gradient Color Style <name>. Exclude this Color Style from exporting by setting "none" in the description field of the Color Style.
Skip this Color Style for now? y/n
> y

Optional: Add ability to skip exporting unsupported Color Styles.
See #49

Export resources to a non-main Bundle

Add ability to export resources to a non-main Bundle.

- MainBundle
- UIComponentsBundle
  -  Assets.xcassets
  -  Color+extension.swift
  -  UIImage+extension.swift
  -  UIFont+extension.swift
  1. Add public keyword to generated structs/classes
  2. Specify Bundle when creating UIImage/Image.

Add support for old iOS versions

CleanShot 2020-08-20 at 20 48 14@2x

CleanShot 2020-08-20 at 20 54 47@2x

Добавить #available API для поддержки цветов на старых версия системы.

Можно вынести в yaml.

[Question] Support multiple pages

Thank you for such a great tool? It saves a ton of time.

I have a couple of questions:

  • Is it possible to import assets from different pages? Is there any way to specify a page for import in the config file?

image

  • Do you have any requirements on how the Figma frame should be named? For example, "Body status emoji", is it a valid name?
    I don't know why but currently, I'm able to import only from the frames on the "Components" page.

Failed when export anything

When I export I get this error. What I can do?

Using FigmaExport to export colors.

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

It is in your Example iOS Demo Project.

Windows

Я правильно понимаю, что это приложение только под MacOS? Есть ли планы по поддержке windows версии?

Provide more format options when exporting Icon for Android

Issue

some of the icons got bypass since the converting from svg to xml format failed.

Reproduce Step

Run the command

figma-export icons -i figma-export.yaml

for this figma file & the yaml file:

---
figma:
  lightFileId: XR1smKALBfAjLaz9v3OdQK

# [optional] Common export parameters
common:
  icons:
    # Name of the Figma's frame where icons components are located
    figmaFrameName: Icons
  images:
    # Name of the Figma's frame where image components are located
    figmaFrameName: Illustrations

# [optional] Android export parameters
android:
  # Relative or absolute path to the `main/res` folder including it. The colors/icons/imags will be exported to this folder
  mainRes: ./app/src/main/res
  # Parameters for exporting icons
  icons:
    # Where to place icons relative to `mainRes`? FigmaExport clears this directory every time your execute `figma-export icons` command
    output: "figma-export-icons"
  images:
    # Where to place images relative to `mainRes`? FigmaExport clears this directory every time your execute `figma-export images` command
    output: "figma-export-images"
    # Image file format: svg, png or webp
    format: webp
    # Format options for webp format only
    webpOptions:
      # Encoding type: lossy or lossless
      encoding: lossy
      # Encoding quality in percents. Only for lossy encoding.
      quality: 85

the following error happened:

2020-10-08T15:03:36+0800 info: Using FigmaExport to export icons to Android Studio project.
2020-10-08T15:03:36+0800 info: Fetching icons info from Figma. Please wait...
2020-10-08T15:03:39+0800 info: Processing icons...
2020-10-08T15:03:39+0800 info: Downloading remote files...
2020-10-08T15:03:39+0800 info: Downloaded 1/79
2020-10-08T15:03:40+0800 info: Downloaded 2/79
...
2020-10-08T15:03:42+0800 info: Downloaded 78/79
2020-10-08T15:03:42+0800 info: Downloaded 79/79
2020-10-08T15:03:42+0800 info: Converting SVGs to XMLs...
-c parsed, so we will convert the SVG files
-in parsed /var/folders/ly/x5_phl3s2x150ff6d56b4hkc0000gn/T/6622183F-631A-433E-AFF2-275C2878A57C
error is In 24_icon_adder_anim.svg:
ERROR @ line 2: <mask> is not supported
error is In 24_icon_adder_bg.svg:
ERROR @ line 2: <mask> is not supported
...
error is In 24_icon_none.svg:
ERROR @ line 2: <mask> is not supported
error is In 24_icon_profile.svg:
ERROR @ line 2: <mask> is not supported
error is Error while parsing 24_icon_social_msg.svg:
Premature end of file.
error is In 24_icon_trophy.svg:
ERROR @ line 2: <mask> is not supported
ERROR @ line 6: <mask> is not supported
Convert 79 SVG files in total, errors found in 20 files
2020-10-08T15:03:43+0800 info: Writting files to Android Studio project...
2020-10-08T15:03:43+0800 info: Done!

Somehow the icons have <mask> data in it, which AndroidStudio can not handle the converting. can we either provide svg format like:

...
android:
  mainRes: ./app/src/main/res
  icons:
    output: "figma-export-icons"
    format: svg
  images:
...

or figure out a way that can make the converting (svg to xml) success, thank!

Version

0.16.1

Failed when export color contain image

issue

when exporting on this Figma file, it failed for image color, is there any way to ignore / skip this type of color 🙂?

> figma-export colors
2020-09-22T10:25:52+0800 info: Using FigmaExport to export colors.
2020-09-22T10:25:52+0800 info: Fetching colors. Please wait...
Error: keyNotFound(CodingKeys(stringValue: "color", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "nodes", intValue: nil), _JSONKey(stringValue: "8:3", intValue: nil), CodingKeys(stringValue: "document", intValue: nil), CodingKeys(stringValue: "fills", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0)], debugDescription: "No value associated with key CodingKeys(stringValue: \"color\", intValue: nil) (\"color\").", underlyingError: nil))

version

I am using v0.13.0

Export Images For Android Studio

This error occurs when exporting images:

figma-export images
2020-12-02T22:08:10+0700 info: Using FigmaExport to export images to Android Studio project.
2020-12-02T22:08:10+0700 info: Fetching images info from Figma. Please wait...
2020-12-02T22:08:23+0700 info: Processing images...
2020-12-02T22:08:23+0700 info: Downloading remote files...
2020-12-02T22:08:23+0700 info: Converting PNG files to WebP...
2020-12-02T22:08:23+0700 info: Writting files to Android Studio project...
Error: Error Domain=NSCocoaErrorDomain Code=4 "“7DC58CEB-19F9-42BB-A4AD-75AE0025FBB7” couldn’t be removed." UserInfo={NSUserStringVariant=(
    Remove
), NSFilePath=/var/folders/mh/lv6z_kq129b34xc4wzrpyf340000gn/T/7DC58CEB-19F9-42BB-A4AD-75AE0025FBB7, NSUnderlyingError=0x7fd35bd2c690 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

Improve error handling

A lot of users see these errors:
Error: Figma API: {"params":["file_key"],"query":["ids"]} are required.
Error: Figma API: Not found

It will be cool to give users more info why this error happens.

Template Image and Original Image for Xcode

FigmaExport is great, we're using it now on a live project, everybody loves it ✨

One of our iOS developers asking: is it possible to export pdf's in "Original Image" render mode, not "Template Image"? If it's not, can it be a feature request? :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.