Skip to content

feat: Build all swift tokens#70

Draft
lebojo wants to merge 3 commits intofeat/ios/build-tokensfrom
feat/ios/build-token-with-sd
Draft

feat: Build all swift tokens#70
lebojo wants to merge 3 commits intofeat/ios/build-tokensfrom
feat/ios/build-token-with-sd

Conversation

@lebojo
Copy link
Copy Markdown
Member

@lebojo lebojo commented Mar 24, 2026

This PR adds the final needs to build the needed tokens for swiftUI

@lebojo lebojo self-assigned this Mar 24, 2026
@lebojo
Copy link
Copy Markdown
Member Author

lebojo commented Mar 24, 2026

Depends on #69

@github-actions
Copy link
Copy Markdown
Contributor

⏭️ Storybook build skipped

  • Reason: pull request is still in draft
  • Changed files inspected: 12
  • Workflow run: View details

Storybook build was intentionally skipped for this PR event.

Relevant files

  • packages/tokens/scripts/scripts/build-tokens/src/build/build-tokens.ts
  • packages/tokens/scripts/scripts/build-tokens/src/build/outputs/swift/ColorTokens/XCAssetsIntefaces.ts
  • packages/tokens/scripts/scripts/build-tokens/src/build/outputs/swift/ColorTokens/create-swift-color-enum.ts
  • packages/tokens/scripts/scripts/build-tokens/src/build/outputs/swift/ColorTokens/process-color-token.ts
  • packages/tokens/scripts/scripts/build-tokens/src/build/outputs/swift/build-swift-tokens.ts
  • ...and 7 more

@github-actions
Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Missing JSON error handling

The parser uses JSON.parse(contents) without a try-catch block. If a .tokens.json file contains malformed JSON, the build process will crash with an unhelpful stack trace instead of a meaningful error message indicating which file failed to parse.

const data = JSON.parse(contents);
Unsafe color value destructuring

The code destructures components and alpha from token.$value without validating that the value is an object with these properties. If a T1 color token has an unexpected format (e.g., a string reference that slipped through the filter or a malformed value), this will throw a runtime TypeError when attempting to access properties on a primitive.

const value = token.$value ?? token.value;
const { components, alpha } = value;
Silent token name collisions

The indexByName function creates a Map using token names as keys. If multiple tokens share the same name (possible when tokens are defined across multiple files or tiers), later tokens silently overwrite earlier ones in the Map. This can lead to incorrect Swift code generation where some tokens are missing or have wrong values, without any warning to the developer.

export function indexByName(tokens: TransformedToken[]): Map<string, TransformedToken> {
    return new Map(tokens.map(t => [t.name, t]));
}

@github-actions
Copy link
Copy Markdown
Contributor

Failed to generate code suggestions for PR

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue: please run yarn format and configure your IDE accordingly, we use 2 spaces for tabs.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants