Screen · Commerce

StoreKit 2 Paywall SwiftUI Screen

A polished SwiftUI paywall you can drop into your app and make your own. Swap the plans, restyle the layout, and connect it to StoreKit. It includes StoreKit 2 products, intro offers, purchase and restore, a transaction listener, a designed error state and a success moment before unlock.

A complete StoreKit 2 paywall: loading skeleton, intro offers, purchase, restore, a transaction listener, a designed error state and a success moment before unlock.

  • SwiftUI
  • iOS 17.0+
  • glass-paywall-screen
Get SwiftPieces Pro

$199 once, every piece included. See how installing works · Sign in

01

What's included

SwiftUI source you own, built on Apple frameworks only.

  • StoreKit 2 products, intro offers, purchase and restore
  • A transaction listener
  • A designed error state
  • A success moment before unlock
  • Built on the Paywall screen

Includes

Paywall. Installed together, automatically.

Requires

In-App Purchase capability

In the Build Kit

Subscription Utility (brief), Onboarding to Paywall (recipe). Your agent builds around this screen in the same design.

Used in

Subscription App (template), Meditation App (template), Travel App (template), Sleep App (template), Smart Home App (template), Weather App (template), Meal Planner (template), Fitness App (template)

02

Implementation notes

How it behaves, what it handles, and the decisions behind it.

Loads products with Product.products(for:), maps them to PaywallPlan including eligible free-trial intro offers, purchases with verification, restores with AppStore.sync() and Transaction.currentEntitlements, and keeps a Transaction.updates listener running so Ask to Buy, renewals and purchases on other devices are finished and unlock the app. While loading, the Paywall screen shows skeleton cards; a load failure shows a designed retry card; purchase failures surface inline through PaywallStatus. A verified unlock plays a brief ring-and-check moment before onUnlocked fires.

Notes

  • PaywallModel is an @Observable @MainActor class you can drive from tests without the view.
  • Pass onDismiss when the screen is embedded (for example inside OnboardingFlowScreen) rather than presented.
  • GlassPaywallScreenExample at the end of GlassPaywallScreen.swift is the screen shown in the preview; copy it as a starting point.

Theming

  • Reads SPTheme from @Environment(\.spTheme) and requires the design-system item. The theme flows into GlassPaywallBlock through the environment, so one assignment styles both.
  • The background runs from accent at 45% to bg. The hero tile, close button and load-error card use spGlass, which turns opaque surfaceElevated under Reduce Transparency.
  • The success moment draws its ring and check in accent; "Try again" uses accent with accentOn text.

Requirements

  • In-App Purchase capability.
  • Products in App Store Connect matching productIDs.