Professional iOS Mileage Tracking App with Automatic Trip Detection
A sophisticated iOS application built with Swift and SwiftUI that automatically detects and tracks your driving trips using Core Location and Core Motion, similar to commercial apps like MileIQ.
- Smart Start: Automatically begins tracking when speed > 5 mph for > 15 seconds
- Intelligent Stop: Automatically ends trips after 2 minutes of no movement
- Core Motion Integration: Uses device motion sensors for accurate automotive activity detection
- Background Processing: Continues tracking even when the app is in the background
- SwiftUI Interface: Modern, responsive design following Apple's Human Interface Guidelines
- Real-time Updates: Live distance tracking and trip status updates
- Intuitive Controls: Simple start/stop buttons with clear visual feedback
- Status Indicators: Clear display of tracking state, permissions, and system health
- Test Case Management: Professional-grade testing framework for systematic validation
- Automated Logging: Complete debug logs with timestamps and GPS accuracy data
- Export Functionality: Generate detailed reports for analysis and debugging
- Mock Mode: Simulated trips for testing without physical movement (DEBUG builds only)
- Core Location Integration: High-accuracy GPS tracking with configurable settings
- Core Motion Detection: Automotive activity recognition using device sensors
- Background Location Updates: Continuous tracking during app backgrounding
- Error Handling: Comprehensive error management and user feedback
- Performance Optimization: Efficient location processing and memory management
- iOS 15.0+ (targets modern iOS features)
- Xcode 14.0+ (for development and building)
- iPhone with GPS (for location tracking)
- Location Permissions (Always or When In Use)
-
Clone the repository
git clone https://github.com/knportal/MileTracker.git cd MileTracker -
Open in Xcode
open MileTracker.xcodeproj
-
Build and Run
- Select your target device or simulator
- Press
Cmd + Rto build and run
- Launch the app on your device
- Grant Location Permissions when prompted
- Choose "Always" for background tracking capability
- Start your first trip by getting in your car and driving
- Get in your car - no need to touch the app
- Start driving - app automatically detects automotive activity
- Trip begins after 15 seconds of driving above 5 mph
- Continue driving - distance updates in real-time
- Park and exit - trip automatically ends after 2 minutes of no movement
- Start Trip: Manually begin tracking
- Stop Trip: Manually end current trip
- Reset Trip: Clear current trip data
- Start Test Case: Begin recording a specific test scenario
- Add Notes: Document test conditions and observations
- End Test Case: Save complete test data
- Export Reports: Generate detailed test case reports
LocationManager: Handles GPS tracking, motion detection, and trip logicContentView: Main SwiftUI interface and user controlsTestCase: Structured data model for test case management- Core Location Integration: GPS accuracy and background processing
- Core Motion Integration: Automotive activity detection
- MVVM Architecture: Clean separation of concerns
- Combine Framework: Reactive programming for UI updates
- Protocol-Oriented Design: Flexible and testable code structure
- Property Wrappers: SwiftUI state management best practices
MileTracker/
โโโ MileTracker/
โ โโโ LocationManager.swift # Core location and motion logic
โ โโโ ContentView.swift # Main UI interface
โ โโโ MileTrackerApp.swift # App entry point
โ โโโ Assets.xcassets/ # App icons and colors
โโโ MileTrackerTests/ # Unit tests
โโโ MileTrackerUITests/ # UI tests
โโโ .cursor/rules/ # Development rules and guidelines
- Swift 5.9+: Modern Swift language features
- SwiftUI: Declarative UI framework
- Core Location: GPS and location services
- Core Motion: Device motion and activity detection
- Combine: Asynchronous event handling
- Deployment Target: iOS 15.0+
- Swift Version: 5.9
- Architectures: arm64 (iPhone), x86_64 (Simulator)
The app includes a comprehensive testing system for systematic validation:
- Create Test Cases: Name and document specific test scenarios
- Record Data: Automatically capture GPS, motion, and trip data
- Export Reports: Generate detailed test case reports
- Analyze Results: Review performance and identify issues
- Simulated Trips: Test without physical movement
- Predefined Routes: Built-in test scenarios
- Manual Controls: Add mock locations and simulate motion
- Real-time Logging: Comprehensive system activity logs
- Status Monitoring: System health and performance metrics
- Export Functionality: Share debug reports for analysis
- GPS Accuracy: 2-16 meters (typical)
- Update Frequency: Configurable distance and time filters
- Background Efficiency: Optimized for battery life
- Start Detection: 15 seconds after speed threshold
- Stop Detection: 2 minutes after last movement
- False Positive Reduction: Motion sensor validation
- Local Storage: All data stored locally on device
- No Cloud Sync: Privacy-focused design
- Optional Export: User controls data sharing
- Location Access: Required for trip tracking
- Motion Detection: Required for automotive activity recognition
- Background Processing: Required for continuous tracking
- Check location permissions in Settings
- Ensure location services are enabled
- Verify GPS signal strength
- Check motion detection permissions
- Ensure device is not in low power mode
- Verify automotive activity is detected
- Grant "Always" location permission
- Check background app refresh settings
- Ensure app is not force-closed
- Status Display: Real-time system status
- Debug Logs: Detailed activity logs
- Health Check: System diagnostics
- Export Reports: Comprehensive debugging data
- Follow Swift API Design Guidelines
- Use SwiftUI best practices
- Implement proper error handling
- Add comprehensive logging
- Test on real devices
- SwiftLint: Follow Swift style guidelines
- Documentation: Comment complex logic
- Testing: Include unit and UI tests
- Performance: Optimize for battery life
This project is developed for educational and personal use. Please respect Apple's developer guidelines and terms of service.
- Apple: Core Location and Core Motion frameworks
- SwiftUI: Modern iOS development framework
- iOS Community: Best practices and development patterns
For questions, issues, or contributions:
- GitHub Issues: Report bugs and feature requests
- Documentation: Check this README and inline code comments
- Testing: Use the built-in test case management system
Built with โค๏ธ using Swift and SwiftUI
MileTracker - Professional mileage tracking for iOS