macOS menu bar app that prevents your Mac from sleeping.
src/
├── Caffeine.xcodeproj/ # Xcode project
└── Caffeine/
├── Classes/
│ ├── CaffeineApp.swift # App entry point (@main)
│ ├── AppDelegate.swift # NSApplicationDelegate
│ ├── Models/
│ │ └── SleepPreventionManager.swift # IOKit sleep assertions
│ ├── ViewModels/
│ │ └── CaffeineViewModel.swift
│ └── Views/
│ ├── MenuBarController.swift # Menu bar icon & menu
│ └── PreferencesView.swift # SwiftUI preferences window
└── Ressources/
├── Assets.xcassets/
├── Info.plist
├── Caffeine.entitlements
└── *.lproj/ # Localizations (12 languages)
- Swift / SwiftUI
- Minimum deployment: macOS 11 (Big Sur)
- Sparkle framework for auto-updates (in
/sparkle) - IOKit for sleep prevention (
IOPMAssertionCreateWithDescription)
MVVM pattern:
- Model:
SleepPreventionManager(singleton) handles IOKit power assertions - ViewModel:
CaffeineViewModelmanages app state and user preferences - Views: SwiftUI
PreferencesView, AppKitMenuBarController
12 supported languages in Ressources/*.lproj/Localizable.strings:
- English, German, Spanish, French, Italian, Japanese, Korean, Dutch, Portuguese, Portuguese (Brazil), Russian, Chinese (Simplified)
When updating user-facing strings:
- Update the source code
- Update all
Localizable.stringsfiles (key must match exactly)
Open src/Caffeine.xcodeproj in Xcode and build.