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.

finish-ipa: claim HealthKit only when the app asks for Health

Duarte Santos12331d55380a
diff --git a/scripts/ios/finish-ipa.sh b/scripts/ios/finish-ipa.sh
index 0603e735f..b3fd0bfb7 100755
--- a/scripts/ios/finish-ipa.sh
+++ b/scripts/ios/finish-ipa.sh
@@ -54,12 +54,17 @@ cp "$PROFILE" "$APP/embedded.mobileprovision"
# The entitlements are the profile's own (application identifier, team), never a debug build's.
openssl smime -inform der -verify -noverify -in "$PROFILE" -out "$WORK/profile.plist" 2>/dev/null
-python3 - "$WORK/profile.plist" "$WORK/entitlements.plist" <<'PY'
+python3 - "$WORK/profile.plist" "$WORK/entitlements.plist" "$APP/Info.plist" <<'PY'
import plistlib, sys
p = plistlib.load(open(sys.argv[1], 'rb'))
e = dict(p['Entitlements'])
e['get-task-allow'] = False
assert e['application-identifier'].endswith('.ch.opengym.app'), e['application-identifier']
+# The profile carries every capability the App ID has (HealthKit for the watch and the Health
+# step); a build whose app doesn't ask for Health yet must not claim it.
+info = plistlib.load(open(sys.argv[3], 'rb'))
+if 'NSHealthShareUsageDescription' not in info:
+ for k in [k for k in e if k.startswith('com.apple.developer.healthkit')]: del e[k]
plistlib.dump(e, open(sys.argv[2], 'wb'))
print('profile:', p['Name'], '| team', p['TeamIdentifier'][0], '| expires', p['ExpirationDate'])
PY