Swift PiecesPro
  • Library
    Screens48Finished, designed screens for real apps.Templates10Complete apps built from the screens.Build Kit24Styles, briefs and recipes for your coding agentEverything58The whole library, with search
  • Docs
  • Pro

Library

  • Screens48
  • Templates10
  • Build Kit24
  • Everything58
  • Docs
  • Pro
  • Account
Get Swift Pieces ProFree library ↗
Swift PiecesPro

Production-ready SwiftUI screens and app templates for iOS. The pieces to build the whole app.

Library

  • Screens
  • Templates
  • Build Kit
  • Everything

Product

  • Pro
  • Your account
  • Sign in

Resources

  • Docs
  • CLI
  • MCP and agents
  • Free library

Social

  • X / Twitter
  • GitHub

SWIFTPIECES PRO

© 2026 Swift Pieces. One payment, lifetime access, per-developer commercial license.

Curated withby Saivion

LibraryTemplatesSleep App

Template · Health

Sleep App

Drift, a sleep and recovery companion for a smart ring: a complete Xcode project with pairing, daily readiness, sleep stages, trends, widgets and three brand presets.

A sleep and recovery app on four tabs. First run pairs the ring on a turning dial, sets a bedtime goal and hands off to a StoreKit 2 paywall. Today pages through daily scores on a tilted card rail with a tick dial; Sleep reads last night's stages; Trends shows the weeks; Profile holds the ring, bedtime reminders, the subscription and sign out.

SwiftUIiOS 17.0+Xcode project 1.0.0sleep-app

Get Swift Pieces Pro

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

01

What's inside

The screens this template wires together, in the order someone meets them.

First run

Welcome, ring pairing on the dial, a bedtime goal, reminders and the StoreKit 2 paywall. Runs once, then records completion.

Screen · Health

Readiness

Daily scores on a rail of tilted cards, paged by a half-circle tick dial you turn.

Screen · Commerce

Purchase

A complete StoreKit 2 purchase: plans load, the purchase runs, success lands, the app unlocks.

Tabs

Today, Sleep, Trends and Profile. Today is the Readiness rail; Sleep is the night's stage timeline.

Screen · Health

Readiness

Daily scores on a rail of tilted cards, paged by a half-circle tick dial you turn.

Screen · Health

Sleep

Last night as a stepped stage timeline you scrub, with stage totals as capsule bars.

Screen · Account

Settings

A settings home with a collapsing profile header, grouped rows, toggles and sign out.

02

What's included

SwiftUI source you own, built on Apple frameworks only.

  • Ring pairing and a bedtime goal set on a turning dial
  • Daily readiness, sleep and recovery scores on a tilted card rail
  • Last night's stages on a scrubbable timeline
  • Weekly trends with capsule columns and a goal figure
  • Readiness and Last Night widgets
  • Three presets: Frost, Velvet and Graphic

Includes

Readiness, Sleep, Settings, Purchase, Paywall. Installed together, automatically.

Requires

In-App Purchase capability

In the Build Kit

Meditation and Sleep (brief). Your agent builds around this template in the same design.

03

Implementation notes

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

SleepApp is one root view. On first launch it runs Drift's own first run: a welcome with the ring drawn over the score card's arc, pairing the ring on the Readiness screen's tick dial (the ticks fill as it pairs), a bedtime goal you set by turning the same dial, then the Purchase screen's StoreKit 2 paywall. Closing, purchasing or restoring finishes onboarding and records it under a completion key, so the root switches to the home on its own.

There is no tab bar. Three round floating buttons carry the app: Sleep on the left, a capsule for Today and Trends in the middle, Profile on the right. Today is the Readiness screen: Sleep, Readiness, Recovery and Balance cards on a tilted rail, with the dial underneath turning through the last fourteen days. Sleep is the Sleep screen: last night as a stepped stage timeline you scrub, with stage totals as capsule bars. Trends stacks each night's stages into capsule columns and sets the share of nights on goal as a giant figure over a grid of dots. Profile is Settings, with sign out back to first run.

Adapting it

  • Products: pass your App Store Connect ids as productIDs. Until they exist, the paywall shows its designed "plans didn't load" state and its close button still finishes onboarding.
  • Your ring: nights and scores come from DriftSample at the top of SleepApp.swift. Map your ring SDK's or HealthKit's samples to [SleepSegment] per night and your scores to ReadinessDay.
  • Pairing: SleepAppPairStep.pair() simulates the ring. Call your SDK's discovery and bonding there and drive the dial's progress from it.
  • Theme: everything follows the theme you set on SleepApp. Without a brand it wears Drift Frost; SPBrandTheme(.driftVelvet) or .driftGraphic re-skin every destination, including the cards, stage colours and motif.

The Xcode project

The download is a complete project on Tuist: SwiftData nights behind a repository protocol; sleep, recovery, balance and readiness scored against a seven-night baseline, with the contributors behind each; pairing with a designed failure and retry; a bedtime goal and wind-down reminders; loading, no data and error states on Sleep; Trends by week and month; Readiness and Last Night widgets; three presets; unit tests and a first-run UI test.

Notes

  • Not @main: put SleepApp() in your own WindowGroup.
  • Enable the In-App Purchase capability before testing purchases. A real ring also needs Bluetooth usage strings, and Apple Health the HealthKit capability.
  • Drift's scores are sample math for general wellness, not medical readings.
  • Previews ship with the file: first run, home, and home in each Drift preset.

04

Keep building

Pieces that work well next to this one.

Template · Health

Meditation App

Stillwater, a calm wellbeing app: a complete Xcode project with mood check-ins, guided breathing, short courses, a journal, widgets and three brand presets.

Screen · Health

Readiness

Daily scores on a rail of tilted cards, paged by a half-circle tick dial you turn.

Screen · Health

Sleep

Last night as a stepped stage timeline you scrub, with stage totals as capsule bars.