A Native iOS application for solo hikers, featuring smart route tracking and an intelligent backtrack navigation system, even without cell service.
Designed with an Offline-First and Privacy-First approach. All trip data is processed and stored locally on the device (100% On-Device), requiring no external servers or internet connection.
TrailGuide is an iOS application developed with Swift and SwiftUI to enhance the safety of solo hikers navigating through areas with no cellular coverage.
The system acts as a Digital Breadcrumb, continuously recording GPS locations in the background while passing the data through a noise-reduction pipeline to generate the most accurate trail possible.
When it's time to head back, the app automatically generates a Backtrack Navigation route from your recorded data and tracks your position in real-time. If you wander off the safe path, the system issues immediate warnings via on-screen banners and Text-to-Speech (TTS) voice alerts.
All trip records, including paths, distances, and durations, are securely stored inside the device using SwiftData, ensuring full offline capability and absolute data privacy.
- πΊοΈ Real-time route tracking utilizing MapKit and CoreLocation.
- π― Multi-stage GPS noise reduction pipeline for high-precision mapping.
- β©οΈ Automatic generation of backtrack navigation routes.
- π¨ Real-time off-route detection using cross-track distance math.
- π£οΈ Immediate alerts via Text-to-Speech (TTS) and UI banners.
- π Dynamic GPS accuracy adjustment for battery optimization.
- ποΈ Highly maintainable codebase built on Clean Architecture and MVVM.
While hiking, the system continuously records your GPS coordinates. It filters out anomalies, jitters, and stationary noise in the background to draw a smooth and highly accurate trail.
When returning, the system simplifies your raw path into clean waypoints (Path Simplification), drawing a dashed guide line on the map to help you navigate back to your starting point effortlessly.
If you deviate beyond a safe distance from your backtrack route, a red warning banner appears instantly, and the app speaks out loud via Text-to-Speech to guide you back on track.
Upon ending the hike, your total distance, duration, and the precise route polyline are automatically saved into the local SwiftData database, allowing you to review your past adventures anytime.
| Feature | Description |
|---|---|
| πΊοΈ Smart Route Tracking | Real-time trail recording using MapKit and CoreLocation |
| β©οΈ Backtrack Navigation | Automatically generates a return route from recorded data |
| π― GPS Noise Reduction | Multi-stage GPS signal filtering to enhance path accuracy |
| Detects route deviation and alerts the user immediately | |
| π£οΈ Voice & Banner Alert | Delivers warnings via TTS and UI notification banners |
| π Battery Optimization | Dynamically adjusts GPS accuracy to reduce battery consumption |
| πΎ On-Device Storage | Safely stores all trip data locally using SwiftData |
| Category | Technology |
|---|---|
| Language | Swift |
| UI Framework | SwiftUI |
| Architecture | Clean Architecture + MVVM |
| Database | SwiftData |
| Map | MapKit |
| Location | CoreLocation |
| Audio | AVFoundation (AVSpeechSynthesizer) |
| Notifications | UserNotifications |
| Reactive | Combine |
TrailGuide is engineered with Clean Architecture and the MVVM pattern, ensuring clear separation between the Presentation, Domain, and Data layers. This makes the system scalable, testable, and highly maintainable.
SwiftUI Views
β
βΌ
ViewModels (@Observable)
β
βΌ
Domain Use Cases
(e.g., SaveTripUseCase, LocationCalculator)
β
βΌ
Repository Interfaces
βββββββββββββ΄ββββββββββββ
βΌ βΌ
Location Repository TripHistory Repository
β β
βΌ βΌ
CoreLocation Manager SwiftData Context
(Data Source) (Data Source)
TrailGuide
β
βββ App # App Entry Point & DI Container
βββ Core # Utilities & Math formulas (LocationCalculator)
βββ Data
β βββ DataSources # LocationManager, LocalNotificationService
β βββ Models # SwiftData Schemas (TripHistoryModel)
β βββ Repositories # Implementation of Repository Interfaces
βββ Domain
β βββ Entities # Business Models (TripHistory, UserProfileEntity)
β βββ Interfaces # Repository Protocols
β βββ UseCases # SaveTripUseCase, GetAllTripsUseCase, etc.
βββ Presentation
βββ Common # Custom Alerts, Shared UI Components
βββ Features
βββ Breadcrumb # Solo Hike tracking, Map UI, and Backtrack
βββ History # Trip history lists and detailed views
| Folder | Responsibility |
|---|---|
| App | Application entry point and Dependency Injection container. |
| Core | Centralized utilities and complex mathematical functions. |
| Data | Data management layer including Data Sources, Models, and Repositories. |
| Domain | Core business logic encompassing Entities and Use Cases. |
| Presentation | User interface layer containing SwiftUI Views and ViewModels. |
A robust pipeline is implemented in LocationRepositoryImpl to filter raw GPS data before rendering, preventing zigzag jumps or track overlapping in dense forests:
π‘ CoreLocation (Fetches raw GPS from hardware)
β
βΌ
π― Accuracy Filter (Drops coordinates if horizontal accuracy > 35m)
β
βΌ
π Stationary Detection (Pauses recording if speed < 0.5 m/s for over 30s)
β
βΌ
π Speed Anomaly Detection (Drops points if hiking speed exceeds 15 km/h)
β
βΌ
π Distance Filter (Records next point only if moved > 10m from the last point)
β
βΌ
π Moving Average Smoothing (Averages the last 2 points to smooth the trail)
β
βΌ
πΊοΈ MapKit Polyline Rendering (Draws the refined, smooth path on the map)
| Challenge | Solution | Result |
|---|---|---|
| GPS Jitter & Inaccuracy | Developed a multi-stage signal filtering pipeline and applied Moving Average Smoothing. | The path rendered on the map is exceptionally smooth and accurate, eliminating zigzag jumps. |
| Cluttered Backtrack Route | Utilized LocationCalculator.simplifyPath to filter out turns with bearing changes under 30Β°. |
Significantly reduced unnecessary waypoints, making backtrack navigation easier to read and faster to process. |
| Off-Route Detection Accuracy | Calculated Cross-Track Distance between the user's location and the main trail line. | Precisely alerts the user immediately when they stray more than 5 meters from the original path. |
| High Battery Consumption | Dynamically toggled CLLocationManager modes (Battery Saving for normal hiking / High Accuracy for backtracking). |
Conserved battery life during normal use while ensuring maximum safety during backtrack navigation. |
git clone [https://github.com/MarkCnw/TrailGuide-iOS.git](https://github.com/MarkCnw/TrailGuide-iOS.git)
cd TrailGuide-iOS
open TrailGuide.xcodeproj


