StayFocused is an iOS feature-project that lets users define timers to restrict app usage and help them stay focused by leveraging Apple’s Screen Time and Device Activity frameworks. It uses the DeviceActivityMonitor API to schedule start/end events for focus sessions and the Screen Time API to enforce usage limits. The codebase is organized into Swift targets including the main app, a Device Activity extension, and a Widget for quick glance controls.
-
Custom Timer Schedules: Define focus windows with start/end times and app-specific thresholds.
-
Device Activity Monitoring: Automatically trigger extensions at the beginning and end of each timer session using DeviceActivityMonitor.
-
Screen Time Enforcement: Apply ManagedSettings rules to block or limit app usage once the timer expires.
-
Home Screen Widget: Control and view focus sessions directly from the live activity or the dynamic island powered by the TimerActivityWidget target.
-
StayFocused/ – SwiftUI app entry point and views.
-
TimerMonitor/ – Implements DeviceActivityMonitor schedules and thresholds.
-
TimerActivityContent/ – Defines the DeviceActivityReport extension UI.
-
TimerActivityWidget/ – SwiftUI Widget for quick session info.
-
TimerActivityUI/ – Shared UI components for the timer extension.
-
Clone the repository:
git clone https://github.com/killlilwinters/StayFocused-ScreenTimeAPI.git
-
Open
StayFocused.xcodeprojin Xcode. -
In your target's Signing & Capabilities, add the FamilyControls entitlement to your
.entitlementsfile and enable the DeviceActivity capability if needed. -
Build and run on either a physical device or the Simulator (fully supported on Simulator).




