Skip to content

Enhance Error Messaging, Fix README Typos, and Improve Markdown Formatting #257

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

Merged
merged 3 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ The UI-Kit of the example project in Figma:

### Example iOS project

There are 2 example iOS projects in `Example` and `ExampleSwiftUI` directories which demostrates how to use figma-export with UIKit and SwiftUI.
There are 2 example iOS projects in `Example` and `ExampleSwiftUI` directories which demonstrates how to use figma-export with UIKit and SwiftUI.

<img src="../images/figma.png" />

**How to setup iOS project**
1. Open `Example/fastlane/.env` file.
2. Change FIGMA_PERSONAL_TOKEN to your personal Figma token.
3. Go to `Example` folder.
4. Run the following command in Termanal to install cocoapods and fastlane: `bundle install`
5. Run the following command in Termanal to install figma-export: `bundle exec pod install`
4. Run the following command in Terminal to install CocoaPods and Fastlane: `bundle install`
5. Run the following command in Terminal to install figma-export: `bundle exec pod install`

**How to export resources from figma**
* To export colors run: `bundle exec fastlane export_colors`
Expand All @@ -39,7 +39,7 @@ There is an example Android Studio project in `AndroidExample` directory which d

### Example Android Jetpack Compose project

There is an example Android Studio project in `AndroidComposeExample` directory which demostrates how to use `figma-export` configured for Jetpack Compose.
There is an example Android Studio project in `AndroidComposeExample` directory which demonstrates how to use `figma-export` configured for Jetpack Compose.

You can find the generated code for compose in the package `com.redmadrobot.androidcomposeexample.ui.figmaexport`

Expand Down
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ Additionally, the following Swift file will be created to use colors from the co
static var backgroundVideo: UIColor { return UIColor(named: #function)! }
...
}

```

For SwiftUI the following Swift file will be created to use colors from the code.
Expand All @@ -99,7 +98,6 @@ For SwiftUI the following Swift file will be created to use colors from the code
static var backgroundVideo: Color { return Color(#function) }
...
}

```

If you set option `useColorAssets: False` in the configuration file, then will be generated code like this:
Expand Down Expand Up @@ -221,6 +219,7 @@ Example of these files:

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

```kotlin
package com.redmadrobot.androidcomposeexample.ui.figmaexport

Expand All @@ -234,6 +233,7 @@ fun Colors.backgroundPrimary(): Color = colorResource(id = R.color.background_pr
```

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

```kotlin
package com.redmadrobot.androidcomposeexample.ui.figmaexport

Expand All @@ -260,6 +260,7 @@ Vector images will be exported to `drawable` and `drawable-night` directories as
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:

```kotlin
package com.redmadrobot.androidcomposeexample.ui.figmaexport

Expand Down Expand Up @@ -290,16 +291,20 @@ object Typography {
[Download](https://github.com/RedMadRobot/figma-export/releases) the latest release and read [Usage](#usage)

### Homebrew
```

```bash
brew install RedMadRobot/formulae/figma-export
```

If you want to export raster images in WebP format install [cwebp](https://developers.google.com/speed/webp/docs/using) command line utility.
```

```bash
brew install webp
```

### CocoaPods + Fastlane
Add the following line to your Podfile:

```ruby
pod 'FigmaExport'
```
Expand All @@ -308,6 +313,7 @@ This will download the FigmaExport binaries and dependencies in `Pods/` during y
`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:

```ruby
lane :sync_colors do
Dir.chdir("../") do
Expand All @@ -321,6 +327,7 @@ Don't forget to place figma-export.yaml file at the root of the project director
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`
Expand Down Expand Up @@ -413,7 +420,8 @@ Example of `figma-export.yaml` file for iOS project — [Examples/Example/figma-
Example of `figma-export.yaml` file for Android project — [Examples/AndroidExample/figma-export.yaml](./Examples/AndroidExample/figma-export.yaml)

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

```bash
figma-export init --platform android
figma-export init --platform ios
```
Expand Down
2 changes: 1 addition & 1 deletion Sources/FigmaAPI/Model/FigmaClientError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ struct FigmaClientError: Decodable, LocalizedError {
var errorDescription: String? {
switch err {
case "Not found":
return "Figma file not found. Check lightFileId and darkFileId (if you project supports dark mode) in the yaml config file."
return "Figma file not found. Check lightFileId and darkFileId (if your project supports dark mode) in the yaml config file. Also verify that your personal access token is valid and hasn't expired."
default:
return "Figma API: \(err)"
}
Expand Down