Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Watch: Apple Health workout session and heart rate per set

Duarte Santos5ac1c66e8582
diff --git a/frontend/ios/App/Watch/Info.plist b/frontend/ios/App/Watch/Info.plist
index e6bdd6933..6fe4555ff 100644
--- a/frontend/ios/App/Watch/Info.plist
+++ b/frontend/ios/App/Watch/Info.plist
@@ -20,6 +20,14 @@
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
+ <key>NSHealthShareUsageDescription</key>
+ <string>openGym shows your heart rate during a workout and next to each set.</string>
+ <key>NSHealthUpdateUsageDescription</key>
+ <string>openGym saves your workouts to Apple Health when you switch it on.</string>
+ <key>WKBackgroundModes</key>
+ <array>
+ <string>workout-processing</string>
+ </array>
<key>WKApplication</key>
<true/>
<key>WKCompanionAppBundleIdentifier</key>
diff --git a/frontend/ios/App/Watch/OpenGymWatch.entitlements b/frontend/ios/App/Watch/OpenGymWatch.entitlements
new file mode 100644
index 000000000..2ab14a262
--- /dev/null
+++ b/frontend/ios/App/Watch/OpenGymWatch.entitlements
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>com.apple.developer.healthkit</key>
+ <true/>
+ <key>com.apple.developer.healthkit.access</key>
+ <array/>
+</dict>
+</plist>
diff --git a/frontend/ios/App/Watch/OpenGymWatchApp.swift b/frontend/ios/App/Watch/OpenGymWatchApp.swift
index 05ca60802..759bf3a10 100644
--- a/frontend/ios/App/Watch/OpenGymWatchApp.swift
+++ b/frontend/ios/App/Watch/OpenGymWatchApp.swift
@@ -74,6 +74,7 @@ struct IdleView: View {
}
}
}
+ HealthToggle(health: store.health)
}
}
} else {
@@ -155,9 +156,12 @@ struct ExercisePage: View {
.lineLimit(2)
.minimumScaleFactor(0.75)
Spacer(minLength: 4)
- Text("\(index + 1)/\(w.entries.count)")
- .font(.caption2.monospacedDigit())
- .foregroundStyle(.secondary)
+ VStack(alignment: .trailing, spacing: 0) {
+ Text("\(index + 1)/\(w.entries.count)")
+ .font(.caption2.monospacedDigit())
+ .foregroundStyle(.secondary)
+ HeartRateBadge(health: store.health)
+ }
}
SetDots(entry: entry, current: si) { store.pick(set: $0, in: index) }
if let si = si {
@@ -328,3 +332,38 @@ struct RestView: View {
}
}
}
+
+/* ---------- Apple Health ---------- */
+
+/// "♥ 128" while the workout session measures it; nothing otherwise.
+struct HeartRateBadge: View {
+ @ObservedObject var health: WorkoutManager
+
+ var body: some View {
+ if let hr = health.heartRate {
+ Label("\(Int(hr.rounded()))", systemImage: "heart.fill")
+ .font(.caption2.monospacedDigit())
+ .foregroundStyle(.red)
+ .labelStyle(.titleAndIcon)
+ }
+ }
+}
+
+/// Off until switched on: then the workout runs as an Apple Health workout session (heart rate per
+/// set, the app kept awake with the wrist down) and is saved to Apple Health when it ends.
+struct HealthToggle: View {
+ @ObservedObject var health: WorkoutManager
+
+ var body: some View {
+ Toggle(isOn: Binding(
+ get: { health.enabled },
+ set: { on in
+ if on { health.requestAuthorization { ok in health.enabled = ok } } else { health.enabled = false }
+ }
+ )) {
+ Label("Apple Health", systemImage: "heart.fill")
+ }
+ .tint(Theme.accent)
+ .font(.footnote)
+ }
+}
diff --git a/frontend/ios/App/Watch/SessionStore.swift b/frontend/ios/App/Watch/SessionStore.swift
index 46d72fb1b..c5ad2d07a 100644
--- a/frontend/ios/App/Watch/SessionStore.swift
+++ b/frontend/ios/App/Watch/SessionStore.swift
@@ -74,6 +74,12 @@ final class SessionStore: NSObject, ObservableObject, WCSessionDelegate, UNUserN
}
}
@Published private(set) var ready: Ready?
+ /// Apple Health: the workout session, its heart rate, and the switch (WorkoutManager).
+ let health = WorkoutManager()
+ /// When the set now up began: the end of the rest before it, or the start of the session.
+ private var setStartedAt = Date()
+ /// The rest running after a set, for that rest's heart rate once it is over.
+ private var restAfter: (exId: String, entryIdx: Int, setIdx: Int, wid: String, from: Date)?
private var unitDefault = "kg"
private var restDefault: Double = 90
/// A session started here that the phone has not reported back yet.
@@ -178,6 +184,7 @@ final class SessionStore: NSObject, ObservableObject, WCSessionDelegate, UNUserN
guard var next = snap.active else {
// A session started here that the phone has not heard of yet stays.
if self.workout != nil && self.workout?.id == self.startedHere { return }
+ if self.workout != nil { self.health.end(save: true) }
self.workout = nil
self.pending.removeAll()
self.skipRest()
@@ -193,7 +200,11 @@ final class SessionStore: NSObject, ObservableObject, WCSessionDelegate, UNUserN
}
}
self.workout = next
- if !sameWorkout { self.entryIndex = next.cur }
+ if !sameWorkout {
+ self.entryIndex = next.cur
+ self.setStartedAt = Date()
+ if !self.isDemo { self.health.start() }
+ }
if let rest = next.rest {
self.startRest(until: Date(timeIntervalSince1970: rest.endsAt / 1000), notify: true)
}
@@ -215,12 +226,15 @@ final class SessionStore: NSObject, ObservableObject, WCSessionDelegate, UNUserN
func completeSet() {
guard var w = workout, let e = entry, let si = setIndex else { return }
let ei = entryIndex
+ let now = Date()
+ let setFrom = setStartedAt
+ closeRest(at: now)
w.entries[ei].sets[si].done = true
w.entries[ei].sets[si].w = weight
w.entries[ei].sets[si].r = reps
pending.insert("\(e.id)#\(si)")
workout = w
- send(event: [
+ var event: [String: Any] = [
"id": UUID().uuidString,
"type": "setDone",
"wid": w.id ?? "",
@@ -229,12 +243,19 @@ final class SessionStore: NSObject, ObservableObject, WCSessionDelegate, UNUserN
"setIdx": si,
"w": weight,
"r": reps,
- "at": Date().timeIntervalSince1970 * 1000,
- ])
+ "at": now.timeIntervalSince1970 * 1000,
+ ]
+ if let hr = health.stats(from: setFrom, to: now) { event["hr"] = hr }
+ send(event: event)
+ setStartedAt = now
WKInterfaceDevice.current().play(.success)
let rest = e.restSec ?? w.restSec
picked[ei] = nil
- if rest > 0 { startRest(until: Date().addingTimeInterval(rest), notify: true) }
+ if rest > 0 {
+ startRest(until: now.addingTimeInterval(rest), notify: true)
+ // after startRest, which closes any rest before it
+ restAfter = (e.id, ei, si, w.id ?? "", now)
+ }
// On to the next exercise once this one is done.
if setIndex == nil, let next = w.entries.indices.first(where: { $0 > ei && w.entries[$0].sets.contains(where: { !$0.done }) }) {
entryIndex = next
@@ -253,6 +274,9 @@ final class SessionStore: NSObject, ObservableObject, WCSessionDelegate, UNUserN
picked = [:]
pending.removeAll()
loadTargets()
+ setStartedAt = now
+ restAfter = nil
+ health.start()
send(event: [
"id": UUID().uuidString,
"type": "start",
@@ -266,6 +290,8 @@ final class SessionStore: NSObject, ObservableObject, WCSessionDelegate, UNUserN
/// Finishes the session: the phone saves it with its own Finish and save.
func finish() {
guard let w = workout else { return }
+ closeRest(at: Date())
+ health.end(save: true)
send(event: [
"id": UUID().uuidString,
"type": "finish",
@@ -286,6 +312,7 @@ final class SessionStore: NSObject, ObservableObject, WCSessionDelegate, UNUserN
}
func skipRest() {
+ closeRest(at: Date())
restTimer?.invalidate()
restEndsAt = nil
restStartedAt = nil
@@ -312,6 +339,7 @@ final class SessionStore: NSObject, ObservableObject, WCSessionDelegate, UNUserN
restTimer = Timer.scheduledTimer(withTimeInterval: end.timeIntervalSinceNow, repeats: false) { [weak self] _ in
SessionStore.restOverHaptics()
DispatchQueue.main.async {
+ self?.closeRest(at: Date())
self?.restEndsAt = nil
self?.restStartedAt = nil
}
@@ -328,6 +356,24 @@ final class SessionStore: NSObject, ObservableObject, WCSessionDelegate, UNUserN
center.add(UNNotificationRequest(identifier: SessionStore.restNotificationId, content: content, trigger: trigger))
}
+ /// The rest after a set is over (it ran out, was skipped, or the next set is done): its heart
+ /// rate goes to that set, and the next set starts counting from here.
+ private func closeRest(at end: Date) {
+ guard let r = restAfter else { return }
+ restAfter = nil
+ setStartedAt = end
+ guard let hr = health.stats(from: r.from, to: end) else { return }
+ send(event: [
+ "id": UUID().uuidString,
+ "type": "setHr",
+ "wid": r.wid,
+ "exId": r.exId,
+ "entryIdx": r.entryIdx,
+ "setIdx": r.setIdx,
+ "restHr": hr,
+ ])
+ }
+
/// A short, alarm-like pattern on the wrist: three taps.
static func restOverHaptics() {
let device = WKInterfaceDevice.current()
diff --git a/frontend/ios/App/Watch/WorkoutManager.swift b/frontend/ios/App/Watch/WorkoutManager.swift
new file mode 100644
index 000000000..49c9fcd5a
--- /dev/null
+++ b/frontend/ios/App/Watch/WorkoutManager.swift
@@ -0,0 +1,109 @@
+import Foundation
+import HealthKit
+
+/*
+ * Apple Health on the watch, behind the "Apple Health" switch (off until the lifter turns it on):
+ * a strength-training workout session while the phone's workout runs, which shows the live heart
+ * rate here and keeps the watch app running with the wrist down (so the rest still taps the wrist
+ * on time), and the workout saved to Apple Health when it ends. Off, nothing of this runs and
+ * nothing is asked.
+ */
+final class WorkoutManager: NSObject, ObservableObject, HKWorkoutSessionDelegate, HKLiveWorkoutBuilderDelegate {
+ static let enabledKey = "healthEnabled"
+
+ @Published var enabled: Bool = UserDefaults.standard.bool(forKey: WorkoutManager.enabledKey) {
+ didSet { UserDefaults.standard.set(enabled, forKey: WorkoutManager.enabledKey) }
+ }
+ @Published private(set) var heartRate: Double?
+ @Published private(set) var running = false
+
+ private let store = HKHealthStore()
+ private var session: HKWorkoutSession?
+ private var builder: HKLiveWorkoutBuilder?
+ /// Every reading of the session, for the heart rate of each set and rest (SessionStore).
+ private var samples: [(Date, Double)] = []
+
+ /// { avg, max } over a stretch of the session, or nil without readings in it.
+ func stats(from start: Date, to end: Date) -> [String: Double]? {
+ let inside = samples.filter { $0.0 >= start && $0.0 <= end }.map { $0.1 }
+ guard !inside.isEmpty else { return nil }
+ let avg = inside.reduce(0, +) / Double(inside.count)
+ return ["avg": avg.rounded(), "max": (inside.max() ?? avg).rounded()]
+ }
+
+ /// Asks for what the session needs: saving workouts, reading the heart rate.
+ func requestAuthorization(_ done: @escaping (Bool) -> Void) {
+ guard HKHealthStore.isHealthDataAvailable() else { done(false); return }
+ let share: Set<HKSampleType> = [HKObjectType.workoutType()]
+ var read: Set<HKObjectType> = [HKObjectType.workoutType()]
+ if let hr = HKObjectType.quantityType(forIdentifier: .heartRate) { read.insert(hr) }
+ store.requestAuthorization(toShare: share, read: read) { ok, _ in
+ DispatchQueue.main.async { done(ok) }
+ }
+ }
+
+ /// A workout started on the phone: a session here, when the switch is on.
+ func start() {
+ guard enabled, session == nil, HKHealthStore.isHealthDataAvailable() else { return }
+ let config = HKWorkoutConfiguration()
+ config.activityType = .traditionalStrengthTraining
+ config.locationType = .indoor
+ do {
+ let s = try HKWorkoutSession(healthStore: store, configuration: config)
+ let b = s.associatedWorkoutBuilder()
+ b.dataSource = HKLiveWorkoutDataSource(healthStore: store, workoutConfiguration: config)
+ s.delegate = self
+ b.delegate = self
+ session = s
+ builder = b
+ samples = []
+ let now = Date()
+ s.startActivity(with: now)
+ b.beginCollection(withStart: now) { _, _ in }
+ running = true
+ } catch {
+ session = nil
+ builder = nil
+ }
+ }
+
+ /// The workout ended on the phone: saved to Apple Health, or dropped when `save` is false.
+ func end(save: Bool) {
+ guard let s = session, let b = builder else { return }
+ s.end()
+ b.endCollection(withEnd: Date()) { _, _ in
+ if save {
+ b.finishWorkout { _, _ in }
+ } else {
+ b.discardWorkout()
+ }
+ }
+ session = nil
+ builder = nil
+ DispatchQueue.main.async {
+ self.running = false
+ self.heartRate = nil
+ }
+ }
+
+ /* ---------- delegates ---------- */
+
+ func workoutSession(_ workoutSession: HKWorkoutSession, didChangeTo toState: HKWorkoutSessionState, from fromState: HKWorkoutSessionState, date: Date) {}
+
+ func workoutSession(_ workoutSession: HKWorkoutSession, didFailWithError error: Error) {
+ DispatchQueue.main.async { self.running = false }
+ }
+
+ func workoutBuilderDidCollectEvent(_ workoutBuilder: HKLiveWorkoutBuilder) {}
+
+ func workoutBuilder(_ workoutBuilder: HKLiveWorkoutBuilder, didCollectDataOf collectedTypes: Set<HKSampleType>) {
+ guard let hrType = HKQuantityType.quantityType(forIdentifier: .heartRate),
+ collectedTypes.contains(hrType),
+ let stats = workoutBuilder.statistics(for: hrType),
+ let value = stats.mostRecentQuantity()?.doubleValue(for: HKUnit.count().unitDivided(by: .minute())) else { return }
+ DispatchQueue.main.async {
+ self.heartRate = value
+ self.samples.append((Date(), value))
+ }
+ }
+}
diff --git a/frontend/ios/App/Watch/ar.lproj/InfoPlist.strings b/frontend/ios/App/Watch/ar.lproj/InfoPlist.strings
new file mode 100644
index 000000000..61fb7945c
--- /dev/null
+++ b/frontend/ios/App/Watch/ar.lproj/InfoPlist.strings
@@ -0,0 +1,4 @@
+/* openGym on the Apple Watch, ar: Info.plist. Written by ios/ci/watch-strings.mjs. */
+
+"NSHealthShareUsageDescription" = "يعرض openGym نبضك أثناء التمرين وبجانب كل مجموعة.";
+"NSHealthUpdateUsageDescription" = "يحفظ openGym تمارينك في Apple صحتي إذا فعّلت ذلك.";
diff --git a/frontend/ios/App/Watch/bn.lproj/InfoPlist.strings b/frontend/ios/App/Watch/bn.lproj/InfoPlist.strings
new file mode 100644
index 000000000..9ab848eec
--- /dev/null
+++ b/frontend/ios/App/Watch/bn.lproj/InfoPlist.strings
@@ -0,0 +1,4 @@
+/* openGym on the Apple Watch, bn: Info.plist. Written by ios/ci/watch-strings.mjs. */
+
+"NSHealthShareUsageDescription" = "openGym ওয়ার্কআউটের সময় আর প্রতিটি সেটের পাশে আপনার হার্ট রেট দেখায়।";
+"NSHealthUpdateUsageDescription" = "চালু করলে openGym আপনার ওয়ার্কআউট Apple Health-এ সেভ করে।";
diff --git a/frontend/ios/App/Watch/de.lproj/InfoPlist.strings b/frontend/ios/App/Watch/de.lproj/InfoPlist.strings
new file mode 100644
index 000000000..f2547dedc
--- /dev/null
+++ b/frontend/ios/App/Watch/de.lproj/InfoPlist.strings
@@ -0,0 +1,4 @@
+/* openGym on the Apple Watch, de: Info.plist. Written by ios/ci/watch-strings.mjs. */
+
+"NSHealthShareUsageDescription" = "openGym zeigt deinen Puls während des Trainings und neben jedem Satz.";
+"NSHealthUpdateUsageDescription" = "openGym speichert deine Trainings in Apple Health, wenn du das einschaltest.";
diff --git a/frontend/ios/App/Watch/es.lproj/InfoPlist.strings b/frontend/ios/App/Watch/es.lproj/InfoPlist.strings
new file mode 100644
index 000000000..8cb007ef9
--- /dev/null
+++ b/frontend/ios/App/Watch/es.lproj/InfoPlist.strings
@@ -0,0 +1,4 @@
+/* openGym on the Apple Watch, es: Info.plist. Written by ios/ci/watch-strings.mjs. */
+
+"NSHealthShareUsageDescription" = "openGym muestra tu pulso durante el entreno y junto a cada serie.";
+"NSHealthUpdateUsageDescription" = "openGym guarda tus entrenos en Apple Salud si lo activas.";
diff --git a/frontend/ios/App/Watch/fr.lproj/InfoPlist.strings b/frontend/ios/App/Watch/fr.lproj/InfoPlist.strings
new file mode 100644
index 000000000..a503b264f
--- /dev/null
+++ b/frontend/ios/App/Watch/fr.lproj/InfoPlist.strings
@@ -0,0 +1,4 @@
+/* openGym on the Apple Watch, fr: Info.plist. Written by ios/ci/watch-strings.mjs. */
+
+"NSHealthShareUsageDescription" = "openGym affiche ton pouls pendant la séance et à côté de chaque série.";
+"NSHealthUpdateUsageDescription" = "openGym enregistre tes séances dans Apple Santé si tu l’actives.";
diff --git a/frontend/ios/App/Watch/hi.lproj/InfoPlist.strings b/frontend/ios/App/Watch/hi.lproj/InfoPlist.strings
new file mode 100644
index 000000000..1044e578a
--- /dev/null
+++ b/frontend/ios/App/Watch/hi.lproj/InfoPlist.strings
@@ -0,0 +1,4 @@
+/* openGym on the Apple Watch, hi: Info.plist. Written by ios/ci/watch-strings.mjs. */
+
+"NSHealthShareUsageDescription" = "openGym वर्कआउट के दौरान और हर सेट के साथ आपकी धड़कन दिखाता है।";
+"NSHealthUpdateUsageDescription" = "चालू करने पर openGym आपके वर्कआउट Apple Health में सहेजता है।";
diff --git a/frontend/ios/App/Watch/hu.lproj/InfoPlist.strings b/frontend/ios/App/Watch/hu.lproj/InfoPlist.strings
new file mode 100644
index 000000000..1a1f408ac
--- /dev/null
+++ b/frontend/ios/App/Watch/hu.lproj/InfoPlist.strings
@@ -0,0 +1,4 @@
+/* openGym on the Apple Watch, hu: Info.plist. Written by ios/ci/watch-strings.mjs. */
+
+"NSHealthShareUsageDescription" = "Az openGym edzés közben és minden sorozat mellett mutatja a pulzusodat.";
+"NSHealthUpdateUsageDescription" = "Az openGym az Apple Egészség appba menti az edzéseidet, ha bekapcsolod.";
diff --git a/frontend/ios/App/Watch/it.lproj/InfoPlist.strings b/frontend/ios/App/Watch/it.lproj/InfoPlist.strings
new file mode 100644
index 000000000..b42e53266
--- /dev/null
+++ b/frontend/ios/App/Watch/it.lproj/InfoPlist.strings
@@ -0,0 +1,4 @@
+/* openGym on the Apple Watch, it: Info.plist. Written by ios/ci/watch-strings.mjs. */
+
+"NSHealthShareUsageDescription" = "openGym mostra il tuo battito durante l’allenamento e accanto a ogni serie.";
+"NSHealthUpdateUsageDescription" = "openGym salva i tuoi allenamenti in Apple Salute se lo attivi.";
diff --git a/frontend/ios/App/Watch/ko.lproj/InfoPlist.strings b/frontend/ios/App/Watch/ko.lproj/InfoPlist.strings
new file mode 100644
index 000000000..34e6b81b2
--- /dev/null
+++ b/frontend/ios/App/Watch/ko.lproj/InfoPlist.strings
@@ -0,0 +1,4 @@
+/* openGym on the Apple Watch, ko: Info.plist. Written by ios/ci/watch-strings.mjs. */
+
+"NSHealthShareUsageDescription" = "openGym이 운동 중과 각 세트 옆에 심박수를 보여줘요.";
+"NSHealthUpdateUsageDescription" = "켜면 openGym이 운동을 Apple 건강에 저장해요.";
diff --git a/frontend/ios/App/Watch/pl.lproj/InfoPlist.strings b/frontend/ios/App/Watch/pl.lproj/InfoPlist.strings
new file mode 100644
index 000000000..dd4052469
--- /dev/null
+++ b/frontend/ios/App/Watch/pl.lproj/InfoPlist.strings
@@ -0,0 +1,4 @@
+/* openGym on the Apple Watch, pl: Info.plist. Written by ios/ci/watch-strings.mjs. */
+
+"NSHealthShareUsageDescription" = "openGym pokazuje tętno podczas treningu i przy każdej serii.";
+"NSHealthUpdateUsageDescription" = "openGym zapisuje treningi w Apple Zdrowie, jeśli to włączysz.";
diff --git a/frontend/ios/App/Watch/pt-BR.lproj/InfoPlist.strings b/frontend/ios/App/Watch/pt-BR.lproj/InfoPlist.strings
new file mode 100644
index 000000000..1bc6447a0
--- /dev/null
+++ b/frontend/ios/App/Watch/pt-BR.lproj/InfoPlist.strings
@@ -0,0 +1,4 @@
+/* openGym on the Apple Watch, pt-BR: Info.plist. Written by ios/ci/watch-strings.mjs. */
+
+"NSHealthShareUsageDescription" = "O openGym mostra sua frequência cardíaca durante o treino e ao lado de cada série.";
+"NSHealthUpdateUsageDescription" = "O openGym salva seus treinos no Apple Saúde se você ativar.";
diff --git a/frontend/ios/App/Watch/pt-PT.lproj/InfoPlist.strings b/frontend/ios/App/Watch/pt-PT.lproj/InfoPlist.strings
new file mode 100644
index 000000000..87afb8715
--- /dev/null
+++ b/frontend/ios/App/Watch/pt-PT.lproj/InfoPlist.strings
@@ -0,0 +1,4 @@
+/* openGym on the Apple Watch, pt-PT: Info.plist. Written by ios/ci/watch-strings.mjs. */
+
+"NSHealthShareUsageDescription" = "O openGym mostra a tua frequência cardíaca durante o treino e ao lado de cada série.";
+"NSHealthUpdateUsageDescription" = "O openGym guarda os teus treinos no Apple Saúde se o ativares.";
diff --git a/frontend/ios/App/Watch/ru.lproj/InfoPlist.strings b/frontend/ios/App/Watch/ru.lproj/InfoPlist.strings
new file mode 100644
index 000000000..3ca168fbb
--- /dev/null
+++ b/frontend/ios/App/Watch/ru.lproj/InfoPlist.strings
@@ -0,0 +1,4 @@
+/* openGym on the Apple Watch, ru: Info.plist. Written by ios/ci/watch-strings.mjs. */
+
+"NSHealthShareUsageDescription" = "openGym показывает пульс во время тренировки и рядом с каждым подходом.";
+"NSHealthUpdateUsageDescription" = "openGym сохраняет тренировки в Apple Здоровье, если вы это включите.";
diff --git a/frontend/ios/App/Watch/th.lproj/InfoPlist.strings b/frontend/ios/App/Watch/th.lproj/InfoPlist.strings
new file mode 100644
index 000000000..4abae5e3e
--- /dev/null
+++ b/frontend/ios/App/Watch/th.lproj/InfoPlist.strings
@@ -0,0 +1,4 @@
+/* openGym on the Apple Watch, th: Info.plist. Written by ios/ci/watch-strings.mjs. */
+
+"NSHealthShareUsageDescription" = "openGym แสดงอัตราการเต้นของหัวใจระหว่างฝึกและข้างแต่ละเซ็ต";
+"NSHealthUpdateUsageDescription" = "openGym บันทึกการฝึกลงใน Apple Health เมื่อคุณเปิดใช้";
diff --git a/frontend/ios/App/Watch/tr.lproj/InfoPlist.strings b/frontend/ios/App/Watch/tr.lproj/InfoPlist.strings
new file mode 100644
index 000000000..8e5d12fe7
--- /dev/null
+++ b/frontend/ios/App/Watch/tr.lproj/InfoPlist.strings
@@ -0,0 +1,4 @@
+/* openGym on the Apple Watch, tr: Info.plist. Written by ios/ci/watch-strings.mjs. */
+
+"NSHealthShareUsageDescription" = "openGym antrenman sırasında ve her setin yanında nabzını gösterir.";
+"NSHealthUpdateUsageDescription" = "Açarsan openGym antrenmanlarını Apple Sağlık’a kaydeder.";
diff --git a/frontend/ios/App/Watch/uk.lproj/InfoPlist.strings b/frontend/ios/App/Watch/uk.lproj/InfoPlist.strings
new file mode 100644
index 000000000..0e3bc645d
--- /dev/null
+++ b/frontend/ios/App/Watch/uk.lproj/InfoPlist.strings
@@ -0,0 +1,4 @@
+/* openGym on the Apple Watch, uk: Info.plist. Written by ios/ci/watch-strings.mjs. */
+
+"NSHealthShareUsageDescription" = "openGym показує пульс під час тренування і біля кожного підходу.";
+"NSHealthUpdateUsageDescription" = "openGym зберігає тренування в Apple Здоров’я, якщо ти це ввімкнеш.";
diff --git a/frontend/ios/App/Watch/zh-Hans.lproj/InfoPlist.strings b/frontend/ios/App/Watch/zh-Hans.lproj/InfoPlist.strings
new file mode 100644
index 000000000..7f53bee04
--- /dev/null
+++ b/frontend/ios/App/Watch/zh-Hans.lproj/InfoPlist.strings
@@ -0,0 +1,4 @@
+/* openGym on the Apple Watch, zh-Hans: Info.plist. Written by ios/ci/watch-strings.mjs. */
+
+"NSHealthShareUsageDescription" = "openGym 会在训练中和每组旁显示你的心率。";
+"NSHealthUpdateUsageDescription" = "打开后,openGym 会把训练保存到 Apple 健康。";
diff --git a/frontend/ios/App/Watch/zh-Hant.lproj/InfoPlist.strings b/frontend/ios/App/Watch/zh-Hant.lproj/InfoPlist.strings
new file mode 100644
index 000000000..9593d2163
--- /dev/null
+++ b/frontend/ios/App/Watch/zh-Hant.lproj/InfoPlist.strings
@@ -0,0 +1,4 @@
+/* openGym on the Apple Watch, zh-Hant: Info.plist. Written by ios/ci/watch-strings.mjs. */
+
+"NSHealthShareUsageDescription" = "openGym 會在訓練中和每組旁顯示你的心率。";
+"NSHealthUpdateUsageDescription" = "開啟後,openGym 會把訓練儲存到 Apple 健康。";
diff --git a/frontend/ios/ci/watch-strings.mjs b/frontend/ios/ci/watch-strings.mjs
index bb482c8b7..6f645a869 100644
--- a/frontend/ios/ci/watch-strings.mjs
+++ b/frontend/ios/ci/watch-strings.mjs
@@ -76,6 +76,32 @@ const OWN = {
},
}
+// Info.plist's own (the Apple Health permission prompts), into InfoPlist.strings.
+const PLIST = {
+ NSHealthShareUsageDescription: {
+ de: 'openGym zeigt deinen Puls während des Trainings und neben jedem Satz.', fr: 'openGym affiche ton pouls pendant la séance et à côté de chaque série.',
+ es: 'openGym muestra tu pulso durante el entreno y junto a cada serie.', it: 'openGym mostra il tuo battito durante l’allenamento e accanto a ogni serie.',
+ 'pt-PT': 'O openGym mostra a tua frequência cardíaca durante o treino e ao lado de cada série.', 'pt-BR': 'O openGym mostra sua frequência cardíaca durante o treino e ao lado de cada série.',
+ pl: 'openGym pokazuje tętno podczas treningu i przy każdej serii.', hu: 'Az openGym edzés közben és minden sorozat mellett mutatja a pulzusodat.',
+ tr: 'openGym antrenman sırasında ve her setin yanında nabzını gösterir.', ru: 'openGym показывает пульс во время тренировки и рядом с каждым подходом.',
+ uk: 'openGym показує пульс під час тренування і біля кожного підходу.', ar: 'يعرض openGym نبضك أثناء التمرين وبجانب كل مجموعة.',
+ hi: 'openGym वर्कआउट के दौरान और हर सेट के साथ आपकी धड़कन दिखाता है।', bn: 'openGym ওয়ার্কআউটের সময় আর প্রতিটি সেটের পাশে আপনার হার্ট রেট দেখায়।',
+ th: 'openGym แสดงอัตราการเต้นของหัวใจระหว่างฝึกและข้างแต่ละเซ็ต', ko: 'openGym이 운동 중과 각 세트 옆에 심박수를 보여줘요.',
+ 'zh-Hans': 'openGym 会在训练中和每组旁显示你的心率。', 'zh-Hant': 'openGym 會在訓練中和每組旁顯示你的心率。',
+ },
+ NSHealthUpdateUsageDescription: {
+ de: 'openGym speichert deine Trainings in Apple Health, wenn du das einschaltest.', fr: 'openGym enregistre tes séances dans Apple Santé si tu l’actives.',
+ es: 'openGym guarda tus entrenos en Apple Salud si lo activas.', it: 'openGym salva i tuoi allenamenti in Apple Salute se lo attivi.',
+ 'pt-PT': 'O openGym guarda os teus treinos no Apple Saúde se o ativares.', 'pt-BR': 'O openGym salva seus treinos no Apple Saúde se você ativar.',
+ pl: 'openGym zapisuje treningi w Apple Zdrowie, jeśli to włączysz.', hu: 'Az openGym az Apple Egészség appba menti az edzéseidet, ha bekapcsolod.',
+ tr: 'Açarsan openGym antrenmanlarını Apple Sağlık’a kaydeder.', ru: 'openGym сохраняет тренировки в Apple Здоровье, если вы это включите.',
+ uk: 'openGym зберігає тренування в Apple Здоров’я, якщо ти це ввімкнеш.', ar: 'يحفظ openGym تمارينك في Apple صحتي إذا فعّلت ذلك.',
+ hi: 'चालू करने पर openGym आपके वर्कआउट Apple Health में सहेजता है।', bn: 'চালু করলে openGym আপনার ওয়ার্কআউট Apple Health-এ সেভ করে।',
+ th: 'openGym บันทึกการฝึกลงใน Apple Health เมื่อคุณเปิดใช้', ko: '켜면 openGym이 운동을 Apple 건강에 저장해요.',
+ 'zh-Hans': '打开后,openGym 会把训练保存到 Apple 健康。', 'zh-Hant': '開啟後,openGym 會把訓練儲存到 Apple 健康。',
+ },
+}
+
const esc = s => String(s).replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n')
let problems = 0
for (const [pack, lproj] of Object.entries(LANGS)) {
@@ -91,6 +117,12 @@ for (const [pack, lproj] of Object.entries(LANGS)) {
for (const [k, tr] of Object.entries(OWN)) put(k, tr[lproj])
mkdirSync(join(out, `${lproj}.lproj`), { recursive: true })
writeFileSync(join(out, `${lproj}.lproj`, 'Localizable.strings'), lines.join('\n') + '\n')
+ const plist = [`/* openGym on the Apple Watch, ${lproj}: Info.plist. Written by ios/ci/watch-strings.mjs. */`, '']
+ for (const [k, tr] of Object.entries(PLIST)) {
+ if (!tr[lproj] || /—/.test(tr[lproj])) { console.error(`${lproj}: ${k} missing or with an em dash`); problems++; continue }
+ plist.push(`"${k}" = "${esc(tr[lproj])}";`)
+ }
+ writeFileSync(join(out, `${lproj}.lproj`, 'InfoPlist.strings'), plist.join('\n') + '\n')
}
if (problems) process.exit(1)
console.log(`wrote ${Object.keys(LANGS).length} languages`)