DotnetWorkoutKit 1.0.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package DotnetWorkoutKit --version 1.0.0.4                
NuGet\Install-Package DotnetWorkoutKit -Version 1.0.0.4                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DotnetWorkoutKit" Version="1.0.0.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DotnetWorkoutKit --version 1.0.0.4                
#r "nuget: DotnetWorkoutKit, 1.0.0.4"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DotnetWorkoutKit as a Cake Addin
#addin nuget:?package=DotnetWorkoutKit&version=1.0.0.4

// Install DotnetWorkoutKit as a Cake Tool
#tool nuget:?package=DotnetWorkoutKit&version=1.0.0.4                

DotnetWorkoutKit

What is DotnetWorkoutKit?

DotnetWorkoutKit is a cross-platform .NET library that provides a way to create custom workout files for Apple Watch.

Goals

Apple announced the library WorkoutKit in WWDC 2023, which allows developers to create and preview workouts in your iOS and watchOS apps. Refer to the WWDC23 session 10016(timecode: 09:43), the .workout file can be in both binary and JSON format.

However, Apple changed their decision, when the WorkoutKit was officially released, the .workout file is in binary format only. See this reply for more information. This means that developers can't create custom workouts outside of Xcode and MacOS.

So I decoded the binary format of the .workout file and created this library to provide a way to create custom workout files.

Features

  • Create a CustomWorkout with C# code.
  • Save CustomWorkout as a .workout file, which can be previewed on your iPhone and imported to Apple Watch.

Limitations

  • Only support the CustomWorkout type.
  • Only support outdoor running for now.
  • Only support HeartRateRangeAlert and SpeedRangeAlert for now.

Using DotnetWorkoutKit

  1. Create a CustomWorkout and save it as a .workout file.
using DotnetWorkoutKit.Extensions;
using DotnetWorkoutKit.Models;

var customWorkout = new CustomWorkout(
        CustomWorkout.ActivityType.Running, 
        CustomWorkout.LocationType.Outdoor,
        "E8k Interval",
        new WorkoutStep(new DistanceGoal(2, DistanceGoal.DistanceUnitType.Kilometers), null, "warm up"),
        [
            new IntervalBlock([new (IntervalStep.PurposeType.Work, new (new DistanceGoal(8, DistanceGoal.DistanceUnitType.Kilometers), new HeartRateRangeAlert(144, 153)))], 1),
            new IntervalBlock([
                new (IntervalStep.PurposeType.Work, new (new DistanceGoal(100, DistanceGoal.DistanceUnitType.Meters), new SpeedRangeAlert(11, 12))),
                new (IntervalStep.PurposeType.Recovery, new (new TimeGoal(TimeSpan.FromMinutes(2))))
                ], 8)
        ],
        new WorkoutStep(new DistanceGoal(2, DistanceGoal.DistanceUnitType.Kilometers), new SpeedRangeAlert("5'40\"", "5'20\""), "cool down"));

// Save to file
File.WriteAllBytes("test.workout", customWorkout.DataRepresentation());
  1. Share the .workout file to your iPhone through AirDrop or other methods.

  2. You can preview the workout on your iPhone and import it to Apple Watch.

Preview

License

MIT License

Copyright (C) 2013-2024 .NET Foundation and Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1.9 88 12/28/2024
1.0.0.8 86 12/26/2024
1.0.0.4 74 12/26/2024
1.0.0.3 74 12/26/2024
1.0.0 93 12/26/2024