Swiftui

8 posts

toss4 min readCurated summary

Why the Designer Built an App Instead of a Mockup

AI is changing design by letting designers create working prototypes rather than only static mockups. While building Toss’s “underlay” component, the author used SwiftUI, AI, and Metal shaders to design interactions directly on an iPhone. The experience reduced the translation gap between design and development and showed that a functional code prototype can become a more accurate specification than a traditional design document. ## Turning End Screens into New Starting Points - Toss identified screens that appear after users finish tasks, such as completing a transfer or payment. - These “dead ends” usually signal the end of an experience and encourage users to leave the app. - The project aimed to turn them into starting points for new experiences through a reusable component that could work throughout the app. ## The Idea Behind Underlay - Existing notification patterns—bottom sheets, toasts, push notifications, and overlays—attract attention but can interrupt what users are doing. - The author found inspiration in removing a shipping label from a moving box and revealing text that had already existed underneath. - This led to the concept of an **underlay**: instead of placing new information on top of the current screen, the component reveals something beneath it. - The component needed to be recognizable as a feature, preserve the existing experience, and remain reusable across the app. ## Designing Interaction with AI and Code - Figma prototypes showed that underlay’s movement mattered more than its static appearance. - Without experience in Protopie or Framer, the author built an iOS playground in SwiftUI using Xcode and AI. - The designer’s role was to: - Describe the intended experience - Select the best options proposed by AI - Evaluate the result on a real device - The process became a cycle of designing, choosing, testing, and refining. ## Building and Refining the Prototype - The author first created a personal playground for quickly experimenting with layouts, buttons, and text. - Each change was tested through actual device interaction rather than static previews. - The prototype was revised hundreds of times because imagined motion often felt different once implemented. - A scanning-light interaction was created to suggest that AI was reading the screen and finding relevant information. - The visual effect used a Metal shader to control pixel-level properties such as: - Light diffusion - Tint and width - Movement speed - Background darkening - The author gradually began adjusting shader values directly, despite having no prior shader or interaction-tool experience. ## Replacing Interaction Guidelines with a Repository - Instead of preparing a detailed document specifying timing, easing curves, and delays, the author gave developers the working prototype repository. - The developers reproduced the core structure almost immediately because they could inspect and run the implementation directly. - During refinement, the designer adjusted values and interactions directly on the developer’s laptop with AI. - A working reference made communication more precise than phrases such as “the motion feels wrong.” - Both the AI and developers could respond to the same concrete behavior rather than interpreting abstract descriptions. ## Designing the Implementation Structure - The production iOS code ended up closely resembling the prototype’s structure. - This happened because the author had built the prototype for rapid user testing and iteration, not specifically for production. - A well-structured prototype allowed design changes to be communicated through code and reused during implementation. - The article argues that a good design is not only visually convincing; its underlying construction should also be viable. - When a prototype is built in a development-ready way, it can function as the specification rather than disposable code. ## Applying the Approach - Start with the best possible experience instead of limiting ideas to what a familiar design tool can express. - Use AI and code to create a working artifact, since real devices reveal details and textures static tools may hide. - When handing off complex interactions, provide executable code or a repository instead of relying solely on written guidelines. - As AI handles more of the “how,” designers increasingly differentiate themselves through what they choose to imagine and build.

Read original(opens in new tab)
figma2 min readCurated summary

Double Click: When Coding Becomes Conversation | Figma Blog

Vibe coding replaces much of traditional programming with an ongoing conversation with AI: users describe an idea, review the result, and iterate through prompts. It lowers the barrier to creating software and makes experimentation faster, especially for prototypes and side projects. However, the approach can become unreliable as projects grow, producing tangled code and weak internal architecture. ## From Code to Conversation - Andrej Karpathy coined “vibe coding” to describe building software by talking to AI tools such as Cursor Composer and using voice input. - The process emphasizes seeing results, describing changes, running the project, and copying or pasting outputs rather than understanding every line of code. - The idea reflects a broader history of abstraction, from punch cards to assembly, C, Python, and now AI-assisted development. ## Faster, More Accessible Prototyping - Vibe coding lets people express interactive ideas without mastering syntax or a programming language. - Charmaine Lee of Val Town compares it to casually writing in a document or creating a spreadsheet. - Figma designer Nikolas Klein argues that the main benefit is shortening the gap between imagining an interaction and seeing it work. - Replit CEO Amjad Masad reported that 75% of Replit customers never write a line of code. - Figma engineer Vincent van der Meulen used AI to create projects, including a running coach and a loading animation, despite lacking SwiftUI expertise. ## The Complexity Ceiling - Vibe coding is most effective at the beginning of a project, when requirements are simple and experimentation matters more than structure. - As complexity increases, AI-generated solutions may stop fitting together coherently. - Developers can reach a “valley of despair”: an initial burst of progress gives way to difficult debugging and maintenance. - Vincent described ending up with “spaghetti code” and no consistent internal data model after reaching roughly 80% of his goal. Vibe coding is best treated as a powerful prototyping and exploration technique, not a replacement for engineering judgment. Teams should still inspect, test, refactor, and architect AI-generated code when projects become complex or production-critical.

Read original(opens in new tab)
figma2 min readCurated summary

A Year With Dev Mode: 10 Lessons From An Engineering Manager | Figma Blog

After a year using Figma Dev Mode at Decathlon, Laurent Thiebault found it transformative for connecting design and development workflows. The biggest improvement came from Code Connect, which links Figma components to real implementation code and helps resolve mismatches in properties, naming, and states. His overall recommendation is to adopt Dev Mode incrementally, using design tokens, advanced inspection, and embedded documentation to build trust and alignment. ## Start Small, Think Big - Developers may resist adding another tool to established workflows, so the team began with small wins rather than a full process overhaul. - Figma variables helped the team improve design-token handoff. - Variable aliasing creates a clear token hierarchy and supports semantic theming. - Variable scoping prevents incorrect usage, such as applying background colors to text or spacing values to corner radii. - Customized code syntax allows token names to match developer conventions across platforms. - Token changes can expose the corresponding implementation changes directly to developers. ## Use Advanced Inspection Capabilities - Dev Mode handles complex layouts, including Flexbox, and generates implementation-ready code. - Teams can inspect CSS, SwiftUI, UIKit, Android XML, and Jetpack Compose properties. - These inspection tools help designers verify that components are implemented according to specifications. - The Figma VS Code extension adds autocompletion and makes it easier to navigate CSS, Compose, and SwiftUI implementations. ## Define What “Done” Means - Keeping design-system documentation current is difficult, and design intent can be lost during handoff. - Dev Mode documentation and annotations keep requirements closer to the designs themselves. - Designers can add free-text explanations, defined values, measurements, alignment details, and sizing guidance. - Developers can be linked directly to relevant annotations for additional context. - The team documents components with links to GitHub source code, README files, and related playgrounds. ## Code Connect as the Central Improvement - Code Connect connects Figma components directly to the components used in production code. - It helps reconcile differences between how components are structured in design files and how they are implemented in code. - The feature improves consistency around component properties, naming conventions, and state management. - Combined with design tokens and inspection tools, it makes Dev Mode a more reliable bridge between design systems and engineering. Teams adopting Dev Mode should start with focused improvements—especially token management and documentation—then expand toward deeper code integration with Code Connect.

Read original(opens in new tab)
datadog3 min readCurated summary

How we brought Datadog's data visualization to iOS: A focus on performance

Datadog built DogGraphs, a native SwiftUI graphing library, to support complex data visualizations across its iOS app and widgets. Because existing libraries did not meet its needs and the app supported iOS 14, the team had to optimize SwiftUI rendering without newer APIs such as `Canvas`. By combining careful API design, profiling, and a better understanding of SwiftUI’s update model, DogGraphs became a reusable framework used across multiple Datadog products. ## Building DogGraphs for Complex Visualizations - DogGraphs began with the Service Catalog and was designed to support additional Datadog products. - It needed to provide: - Native Swift and SwiftUI rendering - iOS 14 compatibility - Flexible, easy-to-use APIs - Datadog’s default visual style and behavior - Fast rendering for a responsive user experience - The library now powers visualizations in logs, services, dashboards, Bits AI, and mobile widgets. - It supports increasingly diverse graph types as new products integrate with the mobile application. ## A Declarative, Type-Safe API - DogGraphs uses Swift features such as result builders to describe complex graph configurations declaratively, in a style similar to SwiftUI. - Graph definitions can be generated dynamically from server-provided dashboard or widget configurations. - Compile-time type checking prevents invalid combinations, such as stacking incompatible Bar and Line graphs. - Progressive disclosure provides sensible Datadog defaults while still allowing customization when necessary. ## Profiling SwiftUI Performance Datadog’s visualizations can involve metrics, logs, traces, multiple aggregation strategies, arithmetic operations, axes, labels, scales, and color configuration. Query responses are preprocessed by a shared internal service so that formatting and visual behavior remain consistent across platforms. To optimize rendering, the team focused on two primary measurements: - **SwiftUI view body evaluations** - Excessive body evaluations can degrade performance, especially when many views are involved. - Expensive computation should be moved outside view bodies. - `_printChanges()` can reveal why a view is being reevaluated, though it is a private API unsuitable for production use. - **Time Profiler** - Instruments helps identify slow function calls and locate expensive work in the rendering pipeline. Important profiling scenarios included: - Initial graph rendering - Updates caused by window changes, tooltip selection, or layer visibility changes - Device rotation and light/dark mode changes - Interactions with unrelated views such as scroll views, toggles, and buttons ## Understanding SwiftUI’s Update Model The team used Apple’s “Demystify SwiftUI” session to build a mental model for how SwiftUI determines when views should update. - **Identity:** How SwiftUI determines whether an element is the same as, or different from, a previous element. - **Lifetime:** How SwiftUI tracks a view and its associated data over time. - **Dependencies:** How SwiftUI determines which changes require an interface update. - **Diffing:** SwiftUI compares view values to determine what changed, although the exact diffing mechanism is undocumented. Understanding these concepts helps developers explain unexpected view updates and identify the sources of rendering bottlenecks. ## Practical Recommendation For complex SwiftUI components, measure real interaction scenarios rather than relying on assumptions. Track body evaluations and expensive function calls, keep costly work out of `body`, and design APIs that provide efficient defaults while preserving type safety and flexibility.

Read original(opens in new tab)
figma2 min readCurated summary

The Right Code for Your Design System | Figma Blog

Code Connect is Figma’s beta tool for improving design system adoption by connecting design mockups directly to production code. It replaces generic, auto-generated CSS snippets in Dev Mode with an organization’s actual component code, documentation, and usage guidance. Figma argues this can help developers build faster, use components correctly, and avoid creating duplicate one-off solutions. ## The Design System Adoption Problem - Design systems create a shared language between designers and developers. - Figma has already improved the design-to-code connection through: - Auto layout - Variables - Component properties - Dev Mode - A persistent challenge is adoption: - Developers may not know everything a design system contains. - Components and patterns may be used incorrectly. - Teams may create and maintain redundant custom components. - A design system succeeds only when it is used consistently and according to its intended guidelines. ## Code Connect’s Approach - Code Connect lets teams customize the code snippets shown in Figma Dev Mode. - Developers see real design system code rather than automatically generated CSS. - The feature is intended to: - Speed up implementation - Increase design system adoption - Encourage consistent component usage - Reduce duplicated, one-off components ## Connecting Design and Code - Design and development traditionally use different tools and optimize for different goals: - Designers focus on exploration and deciding what to build. - Developers focus on structure, implementation, and maintainability. - Figma presents Code Connect as another step toward allowing both disciplines to move smoothly between creative exploration and systematic implementation. - The tool is designed to address the broader disconnect between design workflows and coding workflows, rather than merely changing individual developer habits. ## Meeting Developers Where They Work - Code Connect is distributed through familiar development ecosystems: - npm for JavaScript and TypeScript projects - Swift Package Manager for SwiftUI projects - Setup instructions and the package are available on GitHub. - Developers can install and configure it through a command-line workflow. - Figma plans to add support for more platforms. - Once installed, design system teams can attach best practices and documentation directly to components and mockups, reducing the need for developers to search through separate documentation or code repositories. Code Connect’s practical recommendation is to bring production-ready component code and guidance into the developer’s existing design-inspection workflow, making the approved design system implementation the easiest option to use.

Read original(opens in new tab)
figma2 min readCurated summary

Codegen Plugins (And Other Tips) for Automating Design to Code | Figma Blog

Codegen in Figma’s Dev Mode is intended as a starting point for design implementation, not a complete replacement for developer judgment. Figma provides built-in snippets, while custom plugins extend code generation for different frameworks, languages, and team conventions. The post highlights several tools that can accelerate design-to-code workflows across web and mobile projects. ## Codegen as a Design-to-Development Starting Point - Codegen automatically generates code from defined design rules or specifications. - Figma argues that generated code should augment—not automate away—the design and development process. - Dev Mode creates code snippets for selected canvas objects in the inspect panel. - Users can choose different programming languages and measurement units. - Teams with mature design systems can build custom codegen plugins to match their conventions. ## Anima: Customizable React and HTML Generation - Exports Figma components into React or HTML with CSS, SCSS, or Tailwind. - Produces interactive, responsive, and maintainable snippets. - Detects repeated components to reduce duplication. - Learns team conventions from added code snippets. - Supports prompts for animations and style-specific adjustments directly in Dev Mode. ## Builder: AI and Code Components - Generates React, Svelte, and HTML using AI. - Can incorporate a team’s existing code components to better align design and implementation. - Allows users to refine output conversationally and train it to match their coding style. - Automatically adapts designs for responsiveness. - Provides a separate web interface for experimenting with generated code outside Figma. ## Figma to Code: Open-Source Multi-Platform Output - Converts designs into responsive web or mobile code. - Supports HTML, Tailwind, Flutter, and SwiftUI. - Lets users preview Tailwind output and copy it into their code editor. - Is available as a free, open-source Figma Community plugin. ## Locofy.ai: Interactive Web and Mobile Code - Generates code for components and full screens in React, HTML/CSS, Next.js, Gatsby, and Vue. - Supports design optimizations such as auto layout and frame grouping. - Adds interactivity through semantic HTML tags, libraries, and actions. - Produces responsive layouts, reusable components, props, and human-readable class names. - Enables teams to share prototypes, bind data, and export code or Storybook files. - Supports direct GitHub synchronization with automatic merging and conflict resolution. The practical recommendation is to use codegen to reach a useful first draft faster, then have designers and developers refine the output against the project’s design system, architecture, and coding standards.

Read original(opens in new tab)
figma2 min readCurated summary

Three Creator Fund projects to know and love | Figma Blog

The Figma Creator Fund supports creators building free plugins, widgets, templates, and educational resources for Figma Community. Since launching in March, it has awarded nearly $300,000 to 13 creators in nine countries, reaching almost a million users. The post highlights how these grants help creators solve difficult, practical problems while keeping their tools freely available. ## The Creator Fund’s Purpose - The program funds resources that expand what creators can do in Figma. - Supported projects include: - Mandarin-language design systems tutorials - Developer-platform education tools - Design-to-code plugins - Free templates and widgets - Figma prioritizes projects that: - Address challenging problems - Save users time - Offer practical value - Can remain free for the wider community - Applicants are encouraged to present a clear vision, invest effort in their application, prepare visuals, and pursue ideas they genuinely care about. ## Figma to Code by Bernardo Ferrari - Based in Curitiba, Brazil, Bernardo Ferrari created Figma to Code, a plugin that converts Figma designs into: - HTML - Tailwind CSS - Flutter - SwiftUI - The project began during the COVID-19 pandemic, when Bernardo helped rebuild a state-level virus-tracking website. - Although he had not worked extensively with web development since 2015, he used Figma as a bridge between design and implementation. ## Problems with Existing Design-to-Code Tools Bernardo found that existing plugins were limited because they were: - Too slow - Dependent on too many steps - Paywalled for full functionality - Incomplete in their support for Figma’s API - Missing important capabilities such as auto layout - Restricted to a single programming language or framework - Weak at handling responsive design and accessibility He spent two months building his own plugin, which launched in July 2020. ## Using the Grant to Modernize the Plugin - Figma and web frameworks evolved significantly after the plugin’s release, but the plugin had fallen behind. - Earlier limitations included: - Only horizontal and vertical padding - Auto layout support limited to “min” and “fixed” - The Creator Fund gave Bernardo the resources to update the plugin without introducing a paid tier. - The grant also enabled him to add support for Figma’s Dev Mode. - He completed the major update in roughly a month and launched it during Config 2023. - Bernardo describes the fund committee as supportive and encouraging toward creators with ambitious ideas. The post’s supplied excerpt ends during Bernardo’s account of launching the update at Config 2023, before the other Creator Fund projects are presented.

Read original(opens in new tab)
figma2 min readCurated summary

Design more, resize less, with Auto Layout | Figma Blog

Figma’s Auto Layout brings structural concepts from CSS flexbox into a free-form design environment. It reduces repetitive resizing and repositioning by making frames respond automatically to their content, while preserving designers’ ability to explore layouts freely. The result is a workflow that feels closer to production code without sacrificing visual experimentation. ## Bridging Design and Development - Traditional Figma designs require manual updates when content changes, such as resizing a button and repositioning neighboring elements. - HTML/CSS and SwiftUI handle these relationships automatically, but are less suited to rapid, free-form design exploration. - Auto Layout combines both approaches by adding flexible, code-inspired layout behavior as a property of any Figma frame. ## How Auto Layout Works - Items inside an Auto Layout frame are arranged vertically or horizontally. - The frame automatically sizes itself based on its contents. - Frames can include padding, fills, strokes, and corner radii, allowing designers to create buttons without extra layers. - Changing button text automatically resizes the button and adjusts surrounding elements. - Spacing is controlled at the container level rather than independently between every pair of items. ## Lists, Menus, and Design Systems - Auto Layout simplifies repeated interface elements such as lists and menus. - Items can be reordered through drag and drop instead of manually repositioning them. - Existing components and design-system elements can be converted using **Shift + A** or the Option menu. - The feature supports more generic components that adapt to different content instead of requiring separate variants. ## Nested Frames and Safeguards - Auto Layout frames can be nested to build complex interfaces, similar to nested HTML `div` elements. - Designers can edit content or move elements in and out of layout frames. - Figma includes safeguards against unintended actions, such as placing a large image inside a button. - Holding **Command** on macOS or **Ctrl** on Windows overrides these safeguards when needed. Figma recommends trying Auto Layout through its playground file, video, and documentation. The initial release was presented as a starting point, with further improvements expected based on user feedback.

Read original(opens in new tab)