Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Shopify Engineering 23 min read Case study mediumAdept

Lessons From Building iOS Widgets

Shopify rebuilt its iOS analytics widgets natively in SwiftUI rather than React Native, because app extensions have tight memory limits, WidgetKit serializes SwiftUI view hierarchies, and React Native had no official widget support. Each widget fetches data independently through Reportify/ShopifyQL while sharing session tokens with the app. iOS calls getTimeline and getSnapshot several times per update cycle, which caused redundant network calls and a token-refresh race that logged users out. A one-minute per-widget cache keyed on configuration fixed both problems. The post also covers a flexible metric decoder, a size-agnostic SwiftUI layout built on LazyVGrid and an OptionSet of layout options, and why relative timestamps were rejected for lack of customization.

Assumes: SwiftUI basicsiOS app extensions

Related posts

  • Lessons From Building Android Widgets

    Shopify Engineering mediumAdept

    Shopify built its Android analytics widgets natively rather than in React Native, because widgets must be built from RemoteViews, which React Native does not support. Widget onUpdate() fires several times per cycle, so a one-minute cache keyed by widget ID removes redundant network calls and incorrect analytics. RemoteViews also append to existing views on each update, which they fixed by calling removeAllViews() before addView(). Charts are drawn from MPAndroidChart as ARGB_8888 bitmaps, relative timestamps were dropped over battery cost, and update flicker is reduced by suppressing updates for 60 seconds after placement and rendering early from cached shared preferences.

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

    Datadog Engineering mediumAdept

    Datadog built DogGraphs, an internal SwiftUI graphing library constrained to iOS 14 (no Canvas), with a result-builder API that type-checks graph compositions at compile time. Profiling with _printChanges() and Xcode Instruments showed that layers observing a shared EnvironmentObject coordinate system caused twice the expected body evaluations (339 vs 113 for a 113-line chart). Moving coordinate-system reduction into the @resultBuilder via TupleGraphContent fixed that. For charts with thousands of bars, a Batch content type groups shapes by fill and stroke style and draws each group as a single Path, which removes the rendering hangs. The post also explains SwiftUI's diffing order: memcmp for POD views, then Equatable, then reflection.

  • Challenges of mixed SwiftUI and UIKit codebases in iOS Apps

    Medium Engineering mediumAdept

    Mixing SwiftUI into Medium's 2013-era UIKit iOS app brings recurring friction: sizing SwiftUI views hosted in UIHostingController as table/collection cells, mismatched scroll APIs (offset sign differs), and duplicated components like PostPreview implemented in both frameworks. Medium keeps UIKit for app-wide navigation and SwiftUI for local feature navigation, avoids SwiftUI TextField due to focus limitations, and notes weaker SwiftUI view debugging. A scroll performance issue from wrapping UILabel with NSAttributedString in a SwiftUI list was fixed by switching to native Text with AttributedString; raising the minimum target from iOS 13 to 16 reduced version-specific code.

  • Migrating Shop app from React Native to native

    Shopify Engineering mediumAdept

    Shopify rebuilt the Shop app from React Native into native Swift/SwiftUI and Kotlin/Jetpack Compose in 12 weeks, with coding agents porting features using the existing React Native app as a reference. Native builds cut cold start by 23% on iOS and 50% on Android, raised session stability from 99.5%+ to 99.95%+, shrank the Android app by 109 MB, reduced Android release build time by about 75%, and reached 120 FPS scrolling on Pixel. The team built a Pi agent extension with subagents for source analysis, planning, implementation and parity review, with plan approval tied to a content hash. They also built Tardis, a tool that exposes live app events, logs and state to agents and compares analytics payloads between the old and new apps. Native expertise, linting, tests and code review were still needed to catch duplication, architectural drift and performance problems in generated code.

  • Five years of React Native at Shopify

    Shopify Engineering easyNovice

    After five years, Shopify has migrated all its mobile apps to React Native, with each team choosing its own migration timing, and reports sub-500ms P75 screen loads, over 99.9% crash-free sessions, and an end to iOS/Android feature-parity work. Hot reloading and TypeScript let engineers move between web and mobile, but native developers and native code remain essential for hardware features, widgets, watch apps and long-running background sync such as Point of Sale offline data. The downsides are flaky debugging, labor-intensive framework upgrades (handled by a rotating group) and heavier reliance on third-party libraries, mitigated with Dependabot and code scanning. Shopify is now extracting shared libraries for identity, monitoring and performance measurement after initially trading consistency for migration speed.

The quest for software engineering knowledge.

Look:
Layout: