Skip to content

dillonvargo/fitnessapp

Repository files navigation

FitTrack - iOS Fitness Tracking App

A comprehensive fitness tracking app built with SwiftUI that helps you monitor body weight, gym workouts, and nutrition intake.

๐Ÿ“ฑ Features

Body Weight Tracking

  • โœ… Daily weight entry with duplicate prevention
  • โœ… Interactive line chart showing weight trends
  • โœ… Optional weekly average visualization
  • โœ… Historical data view

Gym Workout Tracking

  • โœ… Support for Push, Pull, Legs, Cardio workouts
  • โœ… Log exercises with sets, reps, and weight
  • โœ… Track personal records
  • โœ… Visual progress charts per exercise

Diet & Nutrition Tracking

  • โœ… Search foods using USDA FoodData Central API
  • โœ… Automatic macro calculation (calories, protein, carbs, fat)
  • โœ… Manual quantity adjustment
  • โœ… Daily nutrition summary

๐Ÿ›  Tech Stack

  • SwiftUI: Modern declarative UI framework
  • Core Data: Local data persistence
  • Apple Charts: Native charting framework
  • MVVM Architecture: Clean separation of concerns
  • Dark Mode: Full support

๐Ÿ“‚ Project Structure

FitTrackApp/
โ”œโ”€โ”€ FitTrackApp.swift              # App entry point
โ”œโ”€โ”€ ContentView.swift              # Main tab navigation
โ”œโ”€โ”€ Models/
โ”‚   โ”œโ”€โ”€ CoreData/
โ”‚   โ”‚   โ”œโ”€โ”€ FitTrackModel.xcdatamodeld  # Core Data schema
โ”‚   โ”‚   โ””โ”€โ”€ PersistenceController.swift  # Core Data stack
โ”‚   โ””โ”€โ”€ DTOs/
โ”‚       โ”œโ”€โ”€ FoodSearchResult.swift      # USDA API models
โ”‚       โ””โ”€โ”€ NutritionInfo.swift         # Nutrition structures
โ”œโ”€โ”€ ViewModels/
โ”‚   โ”œโ”€โ”€ WeightViewModel.swift           # Weight logic
โ”‚   โ”œโ”€โ”€ WorkoutViewModel.swift          # Workout logic
โ”‚   โ””โ”€โ”€ DietViewModel.swift             # Diet logic
โ”œโ”€โ”€ Views/
โ”‚   โ”œโ”€โ”€ Weight/
โ”‚   โ”‚   โ”œโ”€โ”€ WeightTrackingView.swift
โ”‚   โ”‚   โ””โ”€โ”€ WeightChartView.swift
โ”‚   โ”œโ”€โ”€ Workout/
โ”‚   โ”‚   โ”œโ”€โ”€ WorkoutListView.swift
โ”‚   โ”‚   โ”œโ”€โ”€ AddWorkoutView.swift
โ”‚   โ”‚   โ””โ”€โ”€ ExerciseProgressView.swift
โ”‚   โ””โ”€โ”€ Diet/
โ”‚       โ”œโ”€โ”€ DietTrackingView.swift
โ”‚       โ”œโ”€โ”€ FoodSearchView.swift
โ”‚       โ””โ”€โ”€ AddFoodView.swift
โ”œโ”€โ”€ Services/
โ”‚   โ””โ”€โ”€ USDAFoodService.swift           # API integration
โ””โ”€โ”€ Utilities/
    โ”œโ”€โ”€ DateExtensions.swift            # Date helpers
    โ””โ”€โ”€ Constants.swift                 # App constants

๐Ÿš€ Setup Instructions

Prerequisites

  • macOS 13.0 or later
  • Xcode 15.0 or later
  • iOS 17.0+ deployment target

Step-by-Step Setup

  1. Open Xcode

    • Launch Xcode from your Applications folder
  2. Create New Project

    • Click "Create a new Xcode project"
    • Select "iOS" โ†’ "App"
    • Click "Next"
  3. Configure Project

    • Product Name: FitTrackApp
    • Team: Select your Apple ID (or leave as "None" for simulator only)
    • Organization Identifier: com.yourname.fittrack
    • Interface: SwiftUI
    • Storage: Core Data (CHECK THIS BOX!)
    • Language: Swift
    • Click "Next" and choose save location
  4. Add Files to Project

    • In Xcode's left sidebar (Project Navigator), right-click on "FitTrackApp" folder
    • Select "New Group" and create these folders:
      • Models
      • ViewModels
      • Views
      • Services
      • Utilities
    • For each .swift file in this repository:
      • Right-click the appropriate folder
      • Select "New File" โ†’ "Swift File"
      • Name it exactly as shown
      • Copy and paste the code from this repository
  5. Configure Core Data

    • Delete the default .xcdatamodeld file if it exists
    • Add the FitTrackModel.xcdatamodeld file from this repo
  6. Add Required Frameworks

    • Select your project in the navigator
    • Go to "General" tab
    • Under "Frameworks, Libraries, and Embedded Content", ensure:
      • CoreData.framework is present
      • Charts framework (iOS 16+)
  7. Configure Info.plist for API Access

    • Select Info.plist
    • Add key: NSAppTransportSecurity
    • Add child: NSAllowsArbitraryLoads = YES
    • (Note: For production, configure specific domain exceptions)
  8. Get USDA API Key (Free)

  9. Build and Run

    • Select a simulator (e.g., iPhone 15 Pro)
    • Press โŒ˜R or click the Play button
    • Wait for build to complete
    • App will launch in simulator

Troubleshooting

Build Errors:

  • Ensure all files are added to the target (check File Inspector)
  • Clean build folder: Product โ†’ Clean Build Folder (โ‡งโŒ˜K)
  • Restart Xcode if needed

Core Data Errors:

  • Verify .xcdatamodeld file is included in target
  • Check PersistenceController is properly initialized

API Not Working:

  • Verify API key is correctly entered
  • Check internet connection in simulator
  • Review console logs for error messages

๐ŸŽฏ How to Use the App

Weight Tracking

  1. Tap "Weight" tab
  2. Enter your weight in pounds or kg
  3. Tap "Add Weight"
  4. View your progress on the chart
  5. Toggle "Show Weekly Average" for smoothed trend

Workout Tracking

  1. Tap "Workouts" tab
  2. Tap "+" to add new workout
  3. Select workout type (Push/Pull/Legs/Cardio)
  4. Add exercises with sets, reps, weight
  5. Save workout
  6. View history and progress charts

Diet Tracking

  1. Tap "Diet" tab
  2. Tap "Add Food"
  3. Search for food using USDA database
  4. Adjust serving size
  5. Add to daily log
  6. View daily macro summary

๐Ÿ— Architecture Explained

MVVM Pattern

  • Models: Data structures (Core Data entities)
  • Views: UI components (SwiftUI)
  • ViewModels: Business logic and data management

Core Data

  • Local database on device
  • Persistent storage across app launches
  • Efficient querying and relationships

Why This Structure?

  • Modularity: Each feature is self-contained
  • Testability: ViewModels can be tested independently
  • Maintainability: Easy to find and update code
  • Scalability: Simple to add new features

๐Ÿ”ฎ Future Improvements

High Priority

  • iCloud sync across devices
  • Export data to CSV/PDF
  • Workout templates and routines
  • Nutrition goals and targets
  • Progress photos with timeline

Medium Priority

  • Apple Health integration
  • Widgets for home screen
  • Apple Watch companion app
  • Meal planning and recipes
  • Barcode scanner for food

Low Priority

  • Social features and sharing
  • AI-powered workout suggestions
  • Integration with fitness trackers
  • Custom exercise library
  • Advanced analytics and insights

๐Ÿ“ Code Style Guidelines

  • Comments: Every function and complex logic explained
  • Naming: Clear, descriptive variable and function names
  • Formatting: Consistent indentation and spacing
  • Error Handling: Graceful failures with user feedback

๐Ÿ†˜ Support

For issues or questions:

  1. Check console logs in Xcode (โŒ˜โ‡งY)
  2. Review error messages carefully
  3. Verify all setup steps completed
  4. Check Apple Developer documentation

๐Ÿ“„ License

This is a learning project. Feel free to modify and use for personal projects.


Built with โค๏ธ using SwiftUI

About

An app designed to track weight, food, and gym progress all on one platform

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages