An iOS app that tracks your location history with minimal battery drain and minimal log entries.
The app uses a smart threshold-based tracking algorithm:
- Time Interval — checks your location every N seconds (default: 60s)
- Distance Interval — creates a new log only when you've moved more than N meters (default: 100m)
Every <timeInterval>:
Get current position
Calculate distance from last log
If distance > <distanceInterval>:
→ Close current log (set endTime)
→ Create new log (startTime, lat, lng, no endTime)
Else:
→ Update endTime on current log (extend it)
Result: Sitting at a cafe for 2 hours = 1 log. Walking 500m with 100m threshold = 5 logs.
- SwiftUI — declarative UI
- CoreLocation — background location tracking
- MapKit — map visualization
- JSON file storage — lightweight local persistence
- iOS 16+ — minimum deployment target
- Low accuracy GPS —
kCLLocationAccuracyThreeKilometers(minimal GPS usage) - Throttled polling — only checks at configured intervals (no continuous GPS)
- Distance-based logging — only creates logs when you actually move
- Background mode — uses
allowsBackgroundLocationUpdateswithUIBackgroundModes.location - Auto-pause —
pausesLocationUpdatesAutomatically = true
TraceLog/
├── Package.swift # SPM for core library
├── TraceLogCore/ # Platform-independent code
│ ├── Models/LocationLog.swift # Data model
│ └── Services/
│ ├── StorageService.swift # JSON file persistence
│ └── SettingsService.swift # UserDefaults settings
├── TraceLog/ # iOS app (requires Xcode)
│ ├── TraceLogApp.swift # App entry point + TabView
│ ├── Models/LocationLog.swift # (same as core)
│ ├── Services/
│ │ ├── LocationTracker.swift # CoreLocation + tracking logic
│ │ ├── StorageService.swift # (same as core)
│ │ └── SettingsService.swift # (same as core)
│ ├── Views/
│ │ ├── HomeView.swift # Map + start/stop toggle
│ │ ├── HistoryView.swift # Logs grouped by date
│ │ └── SettingsView.swift # Interval pickers
│ ├── Assets.xcassets/
│ └── Info.plist # Permissions + background modes
swift buildEvery push to main triggers a build. No setup needed — just push.
git add .
git commit -m "your changes"
git pushCheck build status: Actions tab on your GitHub repo page.
Free tier: 2,000 min/month (macOS = 10x multiplier → ~200 real minutes, ~40-60 builds/month).
brew install xcodegenxcodegen generate(creates.xcodeproj)- Open
TraceLog.xcodeprojin Xcode - Select your iPhone → Build & Run
- Grant location permission — "Always Allow" for background tracking
- Tap Start Tracking — begins monitoring your location
- View history — see past logs grouped by date, tap to view on map
- Configure settings — adjust time/distance intervals to balance accuracy vs battery
The app requires:
- Location When In Use — basic tracking while app is open
- Location Always — background tracking when app is closed
- Background Mode: Location — enables tracking in background