---
title: "Lessons From Building iOS Widgets"
description: "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."
url: "https://swe.quest/articles/lessons-from-building-ios-widgets-87bd1407ab4fa628"
canonical: "https://shopify.engineering/lessons-building-ios-widgets"
source: "Shopify Engineering"
published: "2022-09-22"
difficulty: "medium"
kind: "Case study"
reading_minutes: 23
tags: ["mobile","swift","caching","product-engineering"]
---

# Lessons From Building iOS Widgets

A post on [Shopify Engineering](https://swe.quest/sources/shopify.md), published 2022-09-22, 23 min read, Case study. Original: [https://shopify.engineering/lessons-building-ios-widgets](https://shopify.engineering/lessons-building-ios-widgets)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Mobile](https://swe.quest/tags/mobile.md) (Web & mobile)
- [Swift](https://swe.quest/tags/swift.md) (Languages)
- [Caching](https://swe.quest/tags/caching.md) (Backend & APIs)
- [Product engineering](https://swe.quest/tags/product-engineering.md) (Engineering organization)

## Prerequisites

- SwiftUI basics
- iOS app extensions

## Keywords

WidgetKit, SwiftUI, iOS 14, iOS 16, ShopifyQL, Reportify, React Native

## Related posts

- [Lessons From Building Android Widgets](https://swe.quest/articles/lessons-from-building-android-widgets-3b8b116282223e62.md): Shopify Engineering · 2022-09-22 · Medium · 19 min read · Mobile, Caching
  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.
- [How we brought Datadog’s data visualization to iOS: A focus on performance](https://swe.quest/articles/how-we-brought-datadog-s-data-visualization-to-ios-a-focus-on-performance-32d8e749b08067ee.md): Datadog Engineering · 2024-04-18 · Medium · 15 min read · Swift, Mobile, Performance engineering, Frontend
  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.
- [Challenges of mixed SwiftUI and UIKit codebases in iOS Apps](https://swe.quest/articles/challenges-of-mixed-swiftui-and-uikit-codebases-in-ios-apps-2b630ad5ea3f4d4c.md): Medium Engineering · 2024-07-01 · Medium · 4 min read · Mobile, Swift, Refactoring & migrations
  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.
- [Migrating Shop app from React Native to native](https://swe.quest/articles/migrating-shop-app-from-react-native-to-native-d251eff5b6600925.md): Shopify Engineering · 2026-09-10 · Medium · 6 min read · Mobile, React, AI for coding, Refactoring & migrations, Performance engineering
  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.
- [Five years of React Native at Shopify](https://swe.quest/articles/five-years-of-react-native-at-shopify-84f013b1c431ce8f.md): Shopify Engineering · 2025-01-13 · Easy · 9 min read · React, Mobile, Developer productivity, Engineering management
  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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
