A native iOS app that helps optimize your sleep by tracking your "sleep bank" and providing personalized bedtime recommendations.
- Tracks your sleep debt/credit based on recent nights
- Calculates how much you're ahead or behind your sleep goal
- Visual progress indicator showing your current balance
- Tap the goal on the sleep balance card to adjust it without opening settings
- Highlights the lookback windows where you're ahead, and where you're behind
- Offers to switch the sleep bank to the window that needs catching up
- When you're caught up across the whole two-week window, offers to raise your nightly goal to one your recent average already clears
- Personalized bedtime suggestions based on your sleep bank
- Considers your normal wake time and sleep goal
- Adjusts recommendations when you're in sleep debt
- Tap the wake time on the recommendation card to adjust it without opening settings
- View your recent sleep sessions from HealthKit
- Track sleep duration over time
- Visual representation of your sleep patterns
- Automatically filters out duplicate data from sources that occasionally sync multiple times
for a single night (e.g. Oura, after waking up and falling back asleep, refreshing mid-sleep,
or revising values), so a re-synced night doesn't inflate sleep totals by up to 2x or 3x.
Detects older, superseded syncs using the same "Date Added" signal the Health app shows, and
excludes them from Bedger's own calculations. Since HealthKit only lets an app delete data it
wrote itself, this can't mutate HealthKit at all — see
SleepSampleDeduplicator
- Set your personal sleep goal (6-12 hours, in 15 minute steps)
- Configure your preferred wake time
- Adjust the sleep bank calculation period (3-14 days)
- HealthKit Integration: The app reads your sleep data from the Health app
- Sleep Bank Calculation: Compares your actual sleep to your goal over a configurable period
- Smart Recommendations: Suggests bedtime based on your sleep debt/credit and wake time
- Visual Feedback: Clear indicators of your sleep status and progress
- iOS 17.0+
- HealthKit access
- Sleep data recorded in the Health app
- Open the project in Xcode
- Build and run on a device (HealthKit requires a physical device)
- Grant HealthKit permissions when prompted
- Configure your sleep goal and wake time in settings
Sleep sessions are assigned to a calendar day using a "midpoint + 6 hours" rule (see
SleepSession.dateForGrouping). An interactive visualization of this rule lives in
docs/index.html and is published via GitHub Pages (enable Pages →
"GitHub Actions" in repo settings to host it).
- All data stays on your device
- No data is sent to external servers
- HealthKit data is only read, never written to
- SwiftUI: Modern declarative UI framework
- SwiftData: Local data persistence for user preferences
- HealthKit: Sleep data integration
- MVVM Pattern: Clean separation of concerns
The app follows iOS design guidelines and provides a clean, intuitive interface for sleep optimization.