### Installation via Agent Source: https://context7.com/daetojemax/figma-to-swiftui-skill/llms.txt Invoke the Figma to SwiftUI Skill within your agent by providing the Figma design URL. ```APIDOC ## Installation via Agent ### Description Invoke the Figma to SwiftUI Skill within your agent by providing the Figma design URL. ### Usage ``` Use the figma-to-swiftui skill and implement this design: https://www.figma.com/design/abc123/MyApp?node-id=10-5&m=dev ``` ### Usage with Source Document ### Description Invoke the Figma to SwiftUI Skill with a Figma URL and a brief description of the desired screen. ### Usage ``` Use the figma-to-swiftui skill. Implement the Login screen: https://www.figma.com/design/abc123/MyApp?node-id=10-5&m=dev Brief: Sign In validates email/password, disables CTA until valid, shows loading while submitting, shows inline auth errors, navigates to Profile on success. Signup and reset password are out of scope. ``` ``` -------------------------------- ### Installation via CLI Source: https://context7.com/daetojemax/figma-to-swiftui-skill/llms.txt Install the Figma to SwiftUI Skill directly using the provided npm command. ```APIDOC ## Installation via CLI ### Description Install the Figma to SwiftUI Skill directly using the provided npm command. ### Command ```bash npx skills add https://github.com/daetojemax/figma-to-swiftui-skill --skill figma-to-swiftui ``` ``` -------------------------------- ### Install Figma to SwiftUI Skill Source: https://github.com/daetojemax/figma-to-swiftui-skill/blob/master/README.md Use this command to quickly install the skill using npx. Ensure you alias it to 'figma-to-swiftui' for consistent usage. ```bash npx skills add https://github.com/daetojemax/figma-to-swiftui-skill --skill figma-to-swiftui ``` -------------------------------- ### Use Assets in SwiftUI Source: https://context7.com/daetojemax/figma-to-swiftui-skill/llms.txt Examples demonstrate how to use images from an Asset Catalog in SwiftUI, controlling rendering mode, styling, and scaling behavior. ```swift // Single-color UI icon — template so it tints with foreground color Image("closeIcon") .resizable() .renderingMode(.template) .foregroundStyle(Color.secondary) .frame(width: 24, height: 24) // Multi-color logo or illustration — original (no tinting) Image("googleLogo") .resizable() .renderingMode(.original) .frame(width: 24, height: 24) // Hero artwork — fit to container width Image("onboardingHeroArtwork") .resizable() .scaledToFit() .frame(maxWidth: .infinity) // Cropped avatar Image("profilePlaceholder") .resizable() .scaledToFill() .frame(width: 64, height: 64) .clipShape(Circle()) ``` -------------------------------- ### Adaptation Checklist Example Source: https://github.com/daetojemax/figma-to-swiftui-skill/blob/master/references/adaptation-workflow.md Use this format to present a checklist of differences found between existing code and a Figma design. Group changes by category for user review. ```markdown Differences found: ### Structural - ADD: timer card component (lime background, countdown, progress bar) - ADD: illustration header with text overlay - REMOVE: separate winner section — confirm? ### Layout & Spacing - UPDATE: avatar size 56 → 64 - UPDATE: card spacing (avatar ↔ content) 12 → 8 - UPDATE: bottom padding per card 16 → 24 - UPDATE: divider opacity 0.12 → 0.14 ### Typography - UPDATE: title font 17pt medium → 20pt semibold - UPDATE: team name font 17pt → 20pt regular - UPDATE: points font 28pt semibold → 22pt expanded semibold ### Colors & Styling - UPDATE: place badge — gold/silver/bronze gradients → purple gradient for all - UPDATE: background gradient — hardcoded RGB → asset catalog colors ### New Data Requirements - Timer: hardcode or needs API data? - Stats tags: data source needed? ``` -------------------------------- ### SwiftUI Full Typography Style Example Source: https://github.com/daetojemax/figma-to-swiftui-skill/blob/master/references/design-token-mapping.md Implement a complete text style in SwiftUI, including font, width, tracking, line spacing, foreground style, and alignment, based on Figma tokens. ```swift extension Font { static let headingLarge = Font.system(size: 28, weight: .bold) } Text("Title") .font(.headingLarge) .fontWidth(.expanded) .tracking(-0.56) .lineSpacing(34 - 28) .foregroundStyle(Color("textPrimary")) .multilineTextAlignment(.leading) ``` -------------------------------- ### Use Figma to SwiftUI Skill with Figma URL and Brief Source: https://github.com/daetojemax/figma-to-swiftui-skill/blob/master/README.md Provide both the Figma design URL and a text brief to guide the skill's implementation. The brief specifies scope, behavior, and out-of-scope items. ```text Use the figma-to-swiftui skill. Implement this Login screen from Figma: https://www.figma.com/design/abc123/MyApp?node-id=10-5&m=dev. Also read this brief first: Sign In validates email/password, disables the CTA until valid, shows loading while submitting, shows inline auth errors, and navigates to Profile on success. Signup and reset password are out of scope. ``` -------------------------------- ### SwiftUI Card Layout Example Source: https://github.com/daetojemax/figma-to-swiftui-skill/blob/master/references/layout-translation.md Translates a common Figma card layout with padding, background, corner radius, and shadow into SwiftUI code. This pattern is useful for creating distinct content sections. ```swift VStack(alignment: .leading, spacing: 8) { // card content } .padding(16) .background(Color.white) .clipShape(RoundedRectangle(cornerRadius: 12)) .shadow(color: .black.opacity(0.1), radius: 8, x: 0, y: 2) ``` -------------------------------- ### App Button Style with State, Size, and Variant Source: https://github.com/daetojemax/figma-to-swiftui-skill/blob/master/references/component-variants.md Combine multiple variant dimensions like state, size, and style into a single ButtonStyle. This example demonstrates how to manage visual differences based on these properties. ```swift struct AppButtonStyle: ButtonStyle { let variant: ButtonVariant let size: ComponentSize let loadingState: ButtonLoadingState @Environment(\.isEnabled) private var isEnabled func makeBody(configuration: Configuration) -> some View { configuration.label .font(size.font) .padding(.horizontal, size.horizontalPadding) .padding(.vertical, size.verticalPadding) .foregroundStyle(variant.foregroundColor) .background(variant.backgroundColor, in: RoundedRectangle(cornerRadius: size.cornerRadius)) .opacity(configuration.isPressed ? 0.7 : 1.0) .opacity(isEnabled ? 1.0 : 0.5) .overlay { if loadingState == .loading { ProgressView().tint(variant.foregroundColor) } } .allowsHitTesting(loadingState != .loading) } } ``` ```swift // Usage Button("Submit") { submit() } .buttonStyle(AppButtonStyle(variant: .primary, size: .large, loadingState: viewModel.submitState)) .disabled(viewModel.isFormInvalid) ``` -------------------------------- ### Implementing Scroll Views in SwiftUI from Figma Source: https://context7.com/daetojemax/figma-to-swiftui-skill/llms.txt Provides examples for translating Figma's 'clip content' and overflow properties into SwiftUI ScrollViews. Includes implementations for both vertical and horizontal (paging) scrolling behaviors. ```swift // Figma "clip content" + overflow → ScrollView ScrollView(.vertical) { VStack(spacing: 16) { ForEach(items) { item in ItemRow(item: item) } } .padding(.horizontal, 16) } // Paging scroll ScrollView(.horizontal) { LazyHStack { ForEach(pages) { PageView(page: $0) } } } .scrollTargetBehavior(.paging) // iOS 17+ ``` -------------------------------- ### Get Design Context for Assets Source: https://github.com/daetojemax/figma-to-swiftui-skill/blob/master/SKILL.md Retrieves localhost URLs for assets from the Figma design context. Validate these URLs as PNGs before use. ```swift get_design_context ``` -------------------------------- ### Map Figma Tokens to SwiftUI Components Source: https://context7.com/daetojemax/figma-to-swiftui-skill/llms.txt Provides examples for mapping Figma design tokens to SwiftUI elements. Prefer Asset Catalogs for color tokens to ensure automatic dark mode support. Typography mapping includes all relevant fields like size, weight, and line height. ```swift // Color tokens — prefer Asset Catalog for automatic dark mode support Color("textPrimary") // Asset Catalog named color (preferred) extension Color { static var textPrimary: Color { Color("textPrimary") } } // Spacing tokens enum Spacing { static let xs: CGFloat = 4 static let sm: CGFloat = 8 static let md: CGFloat = 12 static let lg: CGFloat = 16 static let xl: CGFloat = 24 static let xxl: CGFloat = 32 } // Typography — carry all fields (size, weight, width, lineHeight, tracking) extension Font { static let headingLarge = Font.system(size: 28, weight: .bold) } Text("Title") .font(.headingLarge) .fontWidth(.expanded) // Figma "Expanded Semibold" needs both weight AND width .tracking(-0.56) .lineSpacing(34 - 28) .foregroundStyle(Color("textPrimary")) // Shadow tokens as View extensions extension View { func shadowSm() -> some View { shadow(color: .black.opacity(0.05), radius: 2, x: 0, y: 1) } func shadowMd() -> some View { shadow(color: .black.opacity(0.1), radius: 8, x: 0, y: 4) } func shadowLg() -> some View { shadow(color: .black.opacity(0.15), radius: 16, x: 0, y: 8) } } // Corner radius tokens enum CornerRadius { static let sm: CGFloat = 4 static let md: CGFloat = 8 static let lg: CGFloat = 12 static let xl: CGFloat = 16 static let full: CGFloat = 9999 // use Capsule() instead of RoundedRectangle } ``` -------------------------------- ### Metadata-First Decision Tree Source: https://github.com/daetojemax/figma-to-swiftui-skill/blob/master/references/fetch-strategy.md This decision tree guides when to run `get_metadata` before `get_design_context` based on the input node's characteristics. It helps determine the most efficient way to fetch design context, especially for complex or multi-screen nodes. ```text Input node ├── Clearly one screen/component │ └── Fetch design context directly ├── Root / page / probably multi-screen container │ └── Run get_metadata first │ ├── One clear child screen -> retarget to that child │ └── Multiple candidates -> build screen map and ask if ambiguous └── Unknown └── Run get_metadata first ``` -------------------------------- ### SwiftUI List Item Layout Example Source: https://github.com/daetojemax/figma-to-swiftui-skill/blob/master/references/layout-translation.md Translates a common Figma list item layout with horizontal auto layout, spacing, and padding into SwiftUI code. This pattern is suitable for rows in lists or tables. ```swift HStack(spacing: 12) { // list item content } .padding(.vertical, 12) .padding(.horizontal, 16) .frame(maxWidth: .infinity, alignment: .leading) ``` -------------------------------- ### Create Scaled PNG Assets for Catalog Source: https://github.com/daetojemax/figma-to-swiftui-skill/blob/master/references/asset-handling.md Copy the 3x source image and use the 'sips' command-line tool to generate 2x and 1x scaled versions for the Xcode Asset Catalog. Adjust dimensions based on the Figma display size and desired scale. ```bash cp source.png assetName@3x.png sips -z 48 48 source.png --out assetName@2x.png sips -z 24 24 source.png --out assetName@1x.png ``` -------------------------------- ### Custom Button State Enum Source: https://github.com/daetojemax/figma-to-swiftui-skill/blob/master/references/component-variants.md Use a custom enum for button states like loading, success, or error when no system equivalent exists. This example shows how to integrate it into a ButtonStyle. ```swift enum ButtonLoadingState { case idle, loading, success, error } struct PrimaryButtonStyle: ButtonStyle { let loadingState: ButtonLoadingState @Environment(\.isEnabled) private var isEnabled func makeBody(configuration: Configuration) -> some View { configuration.label .opacity(configuration.isPressed ? 0.7 : 1.0) .opacity(isEnabled ? 1.0 : 0.5) .overlay { if loadingState == .loading { ProgressView() } } .allowsHitTesting(loadingState != .loading) } } ``` -------------------------------- ### Apply Padding and Background Order in SwiftUI Source: https://github.com/daetojemax/figma-to-swiftui-skill/blob/master/references/layout-translation.md Demonstrates the correct order for applying padding and background modifiers to achieve the desired visual result, similar to Figma's behavior. Incorrect order can lead to unexpected visual outcomes. ```swift content .padding(16) .background(Color.white, in: .rect(cornerRadius: 12)) ``` ```swift content .background(Color.white) .padding(16) ``` -------------------------------- ### Skill Directory Structure Source: https://github.com/daetojemax/figma-to-swiftui-skill/blob/master/README.md Overview of the file and directory structure for the figma-to-swiftui-skill project. Key workflow and reference files are highlighted. ```tree figma-to-swiftui-skill/ SKILL.md — Main workflow references/ source-document.md — Read .txt/.md/spec before Figma; scope and behavior contract screen-discovery.md — Metadata-first mapping for root/page/multi-screen nodes fetch-strategy.md — Timeout-safe metadata/context strategy and dedup rules visual-fidelity.md — Exact value extraction, visual inventory, SwiftUI pitfalls layout-translation.md — Auto Layout → Stacks, sizing, scroll, common patterns responsive-layout.md — Size classes, adaptive layouts, multi-device designs design-token-mapping.md — Figma variables → Color/Font/Spacing tokens component-variants.md — Figma variants → SwiftUI styles and enums asset-handling.md — Figma-rendered PNG assets, xcassets, remote images adaptation-workflow.md — Existing screen adaptation and diff audit figma-mcp-setup.md — MCP connection, troubleshooting ``` -------------------------------- ### Invoke Figma to SwiftUI Skill with Figma URL and Brief Source: https://context7.com/daetojemax/figma-to-swiftui-skill/llms.txt Invoke the skill with a Figma URL and a brief describing the desired implementation. This allows for more specific design requirements. ```bash Use the figma-to-swiftui skill. Implement the Login screen: https://www.figma.com/design/abc123/MyApp?node-id=10-5&m=dev Brief: Sign In validates email/password, disables CTA until valid, shows loading while submitting, shows inline auth errors, navigates to Profile on success. Signup and reset password are out of scope. ``` -------------------------------- ### Use Figma to SwiftUI Skill with Figma URL Source: https://github.com/daetojemax/figma-to-swiftui-skill/blob/master/README.md Initiate the skill by providing the Figma design URL. The skill will then process the design for implementation. ```text Use the figma-to-swiftui skill and implement this design: https://www.figma.com/design/abc123/MyApp?node-id=10-5&m=dev ``` -------------------------------- ### Generate @1x, @2x, @3x Assets Source: https://context7.com/daetojemax/figma-to-swiftui-skill/llms.txt Use shell commands to resize a 3x source image into @1x, @2x, and @3x versions. Ensure the source image is appropriately sized for the desired 3x output. ```bash cp source.png closeIcon@3x.png sips -z 48 48 source.png --out closeIcon@2x.png sips -z 24 24 source.png --out closeIcon@1x.png ``` -------------------------------- ### Adaptive Sizing in SwiftUI Source: https://context7.com/daetojemax/figma-to-swiftui-skill/llms.txt Demonstrates correct methods for adaptive sizing in SwiftUI, avoiding hard-coded screen widths and utilizing `maxWidth`, `containerRelativeFrame`, and `GeometryReader` for flexible layouts. ```swift // WRONG — breaks in Split View, Slide Over, Stage Manager .frame(width: UIScreen.main.bounds.width) .frame(width: 375) // CORRECT — full-width elements .frame(maxWidth: .infinity) // CORRECT — proportional container (iOS 17+) .containerRelativeFrame(.horizontal) { length, _ in length * 0.915 } // CORRECT — GeometryReader for older targets GeometryReader { geo in content.frame(width: geo.size.width * 0.915) } ``` -------------------------------- ### Download Asset via Localhost URL Source: https://github.com/daetojemax/figma-to-swiftui-skill/blob/master/references/asset-handling.md Use curl to download an asset from a local development server. Ensure the URL is active as localhost URLs are ephemeral. Verify the downloaded file is a PNG. ```bash curl -o asset-name.png "http://localhost:PORT/path/to/asset" file asset-name.png ``` -------------------------------- ### Figma MCP Tool: get_design_context Source: https://context7.com/daetojemax/figma-to-swiftui-skill/llms.txt Fetch the full design specification including layout, typography, and colors. The prompt parameter can specify the target platform and framework. ```text get_design_context(fileKey="abc123", nodeId="3166:70147", prompt="generate for iOS using SwiftUI") ``` -------------------------------- ### Call Budget Sanity Check Source: https://github.com/daetojemax/figma-to-swiftui-skill/blob/master/references/fetch-strategy.md This outlines a typical call budget for a single screen, serving as a sanity check. Exceeding this budget signals a need to re-evaluate the fetching strategy. ```text - get_metadata: 0-1 before context, plus 1 if context times out or assets need node IDs - get_design_context: 1 per screen, plus section calls only after split - get_screenshot: 1 for the screen plus one per flattened region or icon asset - get_variable_defs: 1 per `fileKey` - Code Connect lookup: optional, only if the MCP server exposes it ``` -------------------------------- ### Visual Inventory Template Source: https://github.com/daetojemax/figma-to-swiftui-skill/blob/master/references/visual-fidelity.md Use this template to document every screen or component's visual properties before writing SwiftUI code. Ensure every value has a source tag. ```text ─────────── CONTAINER ─────────── size: W x H (fixed / fill-width / fill-height / hug) background: [source: tokens | inline | class] cornerRadius: Xpt [source] border: Xpt, [source] shadow: color=, radius=X, offsetX=X, offsetY=X [source] padding: top=X, leading=X, bottom=X, trailing=X ─────────── LAYOUT ─────────── type: VStack | HStack | ZStack | ScrollView + stack | LazyVGrid | GeometryReader spacing: Xpt alignment: leading | center | trailing (+ cross-axis) ─────────── ELEMENTS ─────────── (one row per visible element) [n] "