3 Plate
Under the glass: how it holds together.
A buyer paying for an iOS app mostly wants to know the hard parts are handled: time, background, extensions. These are the decisions that matter.
A timer engine you can test
Pure Swift with an injected clock. Timers store an end date, so suspending the app, locking the phone or killing the process cannot make them drift.
// A timer stores when it ends, never "seconds left".
enum Phase { case running(end: Date)
case paused(remaining: TimeInterval)
case finished(at: Date) }
func remaining(at now: Date) -> TimeInterval {
switch phase {
case .running(let end): max(0, end.timeIntervalSince(now))
case .paused(let left): left
case .finished: 0 }
}
// time comes from an injected TimeSource, so tests
// "suspend the app for ten minutes" in one line.
21tests passing
0sleep() calls in them
Buttons that run without the app
The Island and lock-screen buttons are LiveActivityIntents. iOS runs them in the app's process and the Live Activity updates straight away.
struct AddMinuteIntent: LiveActivityIntent {
@Parameter(title: "Timer") var timerID: String
func perform() async throws -> some IntentResult {
await MainActor.run { TimerCenter.shared.addMinute(id) }
return .result()
}
}
// Button(intent: AddMinuteIntent(timerID: row.id))
// runs in the app's process, from the lock screen.
One activity, not one per timer
iOS decides which of several activities gets the compact Island slot. Mise runs a single “stove” activity holding every timer, soonest first, so the app controls what leads the Island and the lock screen lists all of them. Timers tick on their own through Text(timerInterval:); no push server is needed.
Ready, even when the app sleeps
The activity has a stale date at the next end time, so iOS re-renders a row as “Ready” on schedule. A local notification covers the sound. State is saved to a shared App Group file the widget reads; SwiftData holds the recipes.