Swiftpack.co - matybrennan/MBHealthTracker as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by matybrennan.
matybrennan/MBHealthTracker push
Health Framework to make using HealthKit simpler
⭐️ 5
🕓 2 weeks ago
.package(url: "https://github.com/matybrennan/MBHealthTracker.git", from: "push")


CI Status Version License Platform


  • Make using HealthKit to a project easy.
  • Enable easy integration for health data.
  • Provide an Open Source project for the iOS open source community.
  • Help others learn about HealthKit.


MBHealthTracker is available through CocoaPods. To install it, simply add the following line to your Podfile: Requires iOS 14.3 and above

pod 'MBHealthTracker'

MBHealthTracker is available through Swift Package Manager, either via Xcode or in Package.swift:

.package(url: "https://github.com/matybrennan/MBHealthTracker", from: "1.1.0"),

Getting Started

Configuration for HealthKit

Add health kit in capabilities through project in "Capabilities"

Add below code to your info.plist

<string>Health want to read your health data</string>
<string>Health wants to write your progress to health store</string>


The main driver that contains all the business logic is MBHealthTracker which can be injected into your services with MBHealthTrackerProtocol

The MBHealthTracker contains all the services below

let tracker = MBHealthTracker()
let configuration = tracker.configuration

Alternatively is you just need a single service you could just inject the protocol needed

let configuration = ConfigurationService()
MyService -> init(configuration: ConfigurationServiceProtocol)
let myService = MyService(configuration: configuration)


  • requestingAuthorization
  • presenting healthKit app

var configuration: ConfigurationServiceProtocol


  • getting sleep
  • saving sleep item

var sleep: SleepServiceProtocol


  • getting mindful sessions
  • saving mindful item

var mindful: MindfulnessServiceProtocol


  • biologicalSex
  • bloodType
  • dateOfBirth
  • skinType
  • isWheelChairUser

var characteristics: CharacteristicServiceProtocol


The ActivityManager contains all the services below and can be injected into your services with ActivityManagerProtocol if you just need this service

let activityManager = ActivityManager()
let activeEnergy = activityManager.activeEnergy

or using MBHealthTracker

let tracker = MBHealthTracker()
let activeEnergy = tracker.activityManager.activeEnergy


Split into sections to gather data based on timeIntervals

  • today, thisWeek, betweenTime

var activeEnergy: ActiveEnergyServiceProtocol


Split into sections to gather data based on timeIntervals

  • last hour, today, thisWeek, betweenTime

var steps: StepsServiceProtocol


  • saveWorkoutItem
  • getWorkouts
  • today, thisWeek, all

var workout: WorkoutManagerProtocol


  • basalBodyTemperature
  • bodyFatPercentage
  • bodyMassIndex
  • bodyTemperature
  • height
  • leanBodyMass
  • waistCircumference
  • weight

var body: BodyServiceProtocol


  • macronutrients
  • minerals
  • ultratrace minerals
  • vitamins
  • hydration
  • caffeine

var nutritionService: NutritionServiceProtocol


Split into sections to gather data based on timeIntervals

  • today, thisWeek, all

var heartRate: HeartRateServiceProtocol

Cycle Tracking

  • abdominalCramps
  • acne
  • appetiteChanges
  • bladderIncontinence
  • bloating
  • breastPain
  • cervicalMucusQuality
  • chills
  • constipation
  • diarrhea
  • drySkin
  • fatigue
  • hairLoss
  • headache
  • hotFlashes
  • menstrualFlow
  • ovulation
  • sexualActivity
  • spotting

var cycleTracking: CycleTrackingServiceProtocol


  • bloodPressure
  • respiratoryRate
  • bloodGlucose
  • bloodOxygen

var vitals: VitalsServiceProtocol


Have a question or an issue about MBHealthTracker? Create an issue!

Interested in contributing to MBHealthTracker? Branch off and create a PR

Apps using this library

Add your app to the list of apps using this library and make a pull request.


MBHealthTracker is available under the MIT license.


Stars: 5
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics