macOS menu bar app that prevents your Mac from sleeping.
- Language: Swift 5
- UI Framework: SwiftUI
- IDE: Xcode
- Platforms: macOS
- Minimum Deployment: macOS 13.5
Strictly follow the Swift/SwiftUI style guide: ~/Agents/Style/swift-swiftui-style-guide.md
All important code changes (fixes, additions, deletions, changes) have to written to CHANGELOG.md. Changelog format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Before writing to CHANGELOG.md:
- Check for new release tags:
git tag --sort=-creatordate | head -1 - Release tags are prefixed with
v(e.g.,v2.0.1) - If a new tag exists that isn't in CHANGELOG.md, create a new version section with that tag's version and date, moving relevant [Unreleased] content under it
Strictly follow the localization guide: ~/Agents/Guides/localization-guide.md
- All user-facing strings must be localized
- Follow formality rules per language
- Consistency is paramount
- Modern SwiftUI patterns:
~/Agents/Guides/swift-modern-development-guide.md - Observable migration:
~/Agents/Guides/swift-observable-migration-guide.md - Swift 6 concurrency:
~/Agents/Guides/swift6-concurrency-guide.md - Swift 6 migration (compact):
~/Agents/Guides/swift6-migration-compact-guide.md - Swift 6 migration (full):
~/Agents/Guides/swift6-migration-full-guide.md
This project uses DZFoundation (~/GIT/Libraries/DZFoundation) for logging.
All debug logging must use:
DZLog("message")— General debug outputDZErrorLog(error)— Conditional error logging (only prints if error is non-nil)
import DZFoundation
DZLog("Starting fetch") // 🔶 fetchData() 42: Starting fetch
DZErrorLog(error) // ❌ MyFile.swift:45 fetchData() ERROR: Network unavailableDo NOT use:
print()for debug outputos.LoggerinstancesNSLog
Both functions are no-ops in release builds.
Local Apple API documentation is available at:
~/Agents/API Documentation/Apple/
The search binary is located inside the documentation folder:
~/Agents/API\ Documentation/Apple/search --help # Run once per session
~/Agents/API\ Documentation/Apple/search "view controller" --language swift
~/Agents/API\ Documentation/Apple/search "NSWindow" --type Class- NEVER edit Xcode project files (
.xcodeproj,.xcworkspace,project.pbxproj,.xcsettings, etc.) - Editing these files will corrupt the project — this is catastrophic and unrecoverable
- Only the user edits project settings, build phases, schemes, and file references manually in Xcode
- If a file needs to be added to the project, stop and tell the user — do not attempt it yourself
- Use
xcodebuildfor building/testing only — never for project manipulation - Exception: Only proceed if the user gives explicit permission for a specific edit
This project uses File System Synchronized Groups (internally PBXFileSystemSynchronizedRootGroup), introduced in Xcode 16. This means:
- The
src/Caffeine/Classes/andsrc/Caffeine/Resources/directories are directly synchronized with the file system - You CAN freely create, move, rename, and delete files in these directories
- Xcode automatically picks up all changes — no project file updates needed
- This is different from legacy Xcode groups, which required manual project file edits
Bottom line: Modify source files in src/Caffeine/Classes/ and src/Caffeine/Resources/ freely. Just never touch the .xcodeproj files themselves.
# Build
xcodebuild -scheme "Caffeine" -destination "platform=macOS" build
# Run tests
xcodebuild -scheme "Caffeine" -destination "platform=macOS" test
# Clean
xcodebuild -scheme "Caffeine" cleanAlways run SwiftFormat after a successful build:
swiftformat .SwiftFormat configuration is defined in .swiftformat at the project root. This enforces:
- 4-space indentation
- Explicit
self.usage - K&R brace style
- Trailing commas in collections
- Consistent wrapping rules
Do not commit unformatted code.
- The style guide emphasizes native SwiftUI patterns over MVVM boilerplate
- Prefer
@Observable(macOS 14+) overObservableObject - Use
async/awaitand.taskmodifier for async work - Avoid Combine unless specifically needed
- Use
DZLog/DZErrorLogfor all debug logging — neverprint() - Always run
swiftformat .after successful builds before committing