This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
LiteStats is a native macOS menu bar application for real-time system monitoring. It is written entirely in Swift with zero external dependencies and requires macOS 14.0+ (Sonoma) and Xcode 15.3+.
This is a pure Xcode project — there are no package managers, build scripts, or Makefiles.
From Xcode:
- Open
LiteStats.xcodeproj - Select the LiteStats scheme
- Set Signing & Capabilities → Team to your Apple ID
- Press
⌘R
From the command line:
xcodebuild -project LiteStats/LiteStats.xcodeproj -scheme LiteStats -configuration Debug buildThere are no unit tests in this project.
The app uses a clean three-layer separation:
| File | Role |
|---|---|
LiteStatsApp.swift |
@main entry point; creates MenuBarExtra scene; passes StatsModel to views |
StatsModel.swift |
@Observable polling engine; all system metric collection logic |
ContentView.swift |
Menu bar panel UI (340pt fixed width); StatRow and ProgressBar components |
PreferencesView.swift |
Settings sheet (interval slider, device info display) |
PreferencesWindowController.swift |
Singleton NSWindow wrapper for preferences; prevents duplicate windows |
@Observableclass (Swift 5.9 Observation framework), lives on the main actor via@Statein the app entry point.- Timer is added to
.commonRunLoop mode so it fires during UI tracking loops. - CPU: Delta between successive
host_cpu_load_infosnapshots — avoids the first-read 100% spike. Raw ticks are stored aspreviousCPULoadfor the next calculation. - RAM:
active + wired + compressorpages fromhost_statistics64(HOST_VM_INFO64). - Storage:
URL.resourceValueson the boot volume root. - Battery: Level and charging state from
IOPowerSources; health % and cycle count fromAppleSmartBatteryIORegistry entry (MaxCapacity / DesignCapacity).
- Sandboxing is disabled (
com.apple.security.app-sandbox = falseinInfo.plist) — required for IOKit battery access. Do not enable the sandbox without adding appropriate entitlements or a helper process. - No Dock icon:
LSUIElement = YESinInfo.plisthides the app from Dock and App Switcher. - The preferences window uses a standalone
NSWindow(not a SwiftUISheetorWindowGroup) to avoid stealing focus from the menu bar panel.