HealthKitDataGenerator

0.1.0

Swift Package for generating realistic HealthKit data with AI-powered natural language processing, custom profiles, and flexible configuration options for iOS development and testing.
aminbenarieb/healthkit-data-generator

What's New

Release 0.1.0: Initial release with Swift package and demo app

2025-10-11T07:42:07Z

Initial Release - HealthKit Data Generator

A comprehensive Swift Package Manager library for generating realistic HealthKit data for iOS development and testing.

Key Features

AI-Powered Generation

  • Natural Language Processing: Generate health data from natural language descriptions
  • Apple Foundation Model Integration: Native on-device AI for iOS 26.0+
  • Custom LLM Provider Support: Extensible architecture for custom AI providers

Manual Data Generation

  • Preset Health Profiles: Sporty, Balanced, Stressed, Sedentary, Athletic
  • Custom Profiles: Create personalized health profiles
  • Flexible Date Ranges: Last N days, specific ranges, single days
  • Generation Patterns: Continuous, sparse, weekdays only, weekends only

Developer Tools

  • JSON Import/Export: Flexible data exchange
  • Comprehensive Testing: Full test coverage with Swift Testing framework
  • SwiftUI Demo App: Complete example implementation
  • HealthKit Integration: Seamless data population

Demo App Included

This repository includes a SwiftUI demo app (HealthKitDataGeneratorApp/) showcasing:

  • Manual health data generation with intuitive UI
  • AI-powered natural language generation
  • Real-time health data visualization
  • Both manual and AI-powered modes

Quick Start

import HealthKitDataGenerator
import HealthKit

let healthStore = HKHealthStore()
let generator = HealthKitDataGenerator(healthStore: healthStore)

// Generate 7 days of data with sporty profile
let config = SampleGenerationConfig(
    profile: .sporty,
    dateRange: .lastDays(7)
)

let allTypes = HealthKitConstants.authorizationWriteTypes()
try generator.generateAndPopulate(samplesTypes: allTypes, config: config)

🔗 Documentation

🏗️ Installation

Add to your Package.swift:

dependencies: [
    .package(url: "https://github.com/aminbenarieb/healthkit-data-generator", from: "0.1.0")
]

HealthKit Data Generator

CI License: MIT

Overview

HealthKitDataGenerator is a comprehensive Swift package that provides tools for:

  • Data Generation: Create realistic sample health data for testing
  • Data Export: Export HealthKit data to JSON format with flexible configuration
  • Data Import: Import health data from JSON profiles into HealthKit

Demo Videos

Manual Generation LLM Generation
manual.mp4
llm.mov

Acknowledgments

This project is inspired by and builds upon the excellent work done in healthkit-sample-generator by Michael Seemann. While this SPM package is a complete rewrite with modern Swift features, LLM integration, and enhanced functionality, we acknowledge the foundational concepts and approaches from the original project.

Installation

Swift Package Manager

Add the HealthKitDataGenerator package to your project:

dependencies: [
    .package(url: "https://github.com/aminbenarieb/healthkit-data-generator", from: "1.0.0")
]

Usage

Preset Profiles

import HealthKitDataGenerator
import HealthKit

let healthStore = HKHealthStore()
let generator = HealthKitDataGenerator(healthStore: healthStore)

// Generate 7 days of data with sporty profile
let config = SampleGenerationConfig(
    profile: .sporty,
    dateRange: .lastDays(7)
)

let allTypes = HealthKitConstants.authorizationWriteTypes()
try generator.generateAndPopulate(samplesTypes: allTypes, config: config)

Quick Presets

// Last week - sporty profile
let config1 = SampleGenerationConfig.lastWeekSporty()

// Last month - balanced profile
let config2 = SampleGenerationConfig.lastMonthBalanced()

// Last week - stressed profile
let config3 = SampleGenerationConfig.lastWeekStressed()

try generator.generateAndPopulate(samplesTypes: allTypes, config: config1)

Comprehensive Examples

This repository includes a SwiftUI demo app (HealthKitDataGeneratorApp/) showcasing all package features with an intuitive interface for both manual and AI-powered health data generation.

For detailed usage examples covering all features, see USAGE_EXAMPLES.md which includes custom profiles, date ranges, metric selection, generation patterns, LLM integration, and app integration examples.

🤖 AI-Powered Health Data Generation

The LLMManager enables AI-powered health data generation from natural language descriptions. It supports multiple LLM providers through a unified interface and automatically routes requests to the best available provider.

import HealthKitDataGenerator
import HealthKit

let healthStore = HKHealthStore()
let llmManager = LLMManager()

// Generate health data from natural language
let response = try await llmManager.generateHealthConfig(from: 
    "Create 2 weeks of marathon training data for an athlete with high activity, excellent sleep, and high-protein diet"
)

// Import the generated configuration
let generator = HealthKitDataGenerator(healthStore: healthStore)
try generator.importFromLLMJSON(response.json)

Current LLM Provider

Apple Foundation Model (iOS 26.0+): Native integration with Apple's on-device AI model

Extending with Custom Providers

You can add custom LLM providers by implementing the LLMProvider protocol:

class CustomLLMProvider: LLMProvider {
    let identifier = "custom_provider"
    let name = "Custom LLM"
    var isAvailable: Bool { true }
    
    func generateHealthConfig(from prompt: String) async throws -> String {
        // Your custom LLM integration
        return generatedJSON
    }
    
    func canHandle(_ prompt: String) -> Bool {
        // Determine if this provider can handle the request
        return true
    }
}

// Register your provider
llmManager.register(CustomLLMProvider())

The generated JSON follows the schema defined in LLM_JSON_SCHEMA.md, supporting both configuration-based generation and direct sample specification.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Description

  • Swift Tools 6.0.0
View More Packages from this Author

Dependencies

Last updated: Wed Nov 26 2025 06:48:45 GMT-1000 (Hawaii-Aleutian Standard Time)