# Building Fit-or-Fat for iPhone (on a Mac)

This folder is a Capacitor 8 iOS project. These steps are written so they can be followed
verbatim — or handed to Claude Code on the Mac ("follow BUILD-IOS.md in this folder").

## Prerequisites (one-time)

- Xcode from the Mac App Store (open it once to accept the license)
- Homebrew, then: `brew install cocoapods node`

## Build steps

```bash
# from the unzipped project root (the folder containing this file)
npm install --legacy-peer-deps   # REQUIRED flag: @perfood/capacitor-healthkit declares an old Capacitor peer
npx cap sync ios
cd ios/App
pod install
open App.xcworkspace             # the .xcworkspace, NOT the .xcodeproj
```

In Xcode, select the **App** target → **Signing & Capabilities**:

1. Tick "Automatically manage signing", pick your **Team** (personal Apple ID works —
   add it under Xcode → Settings → Accounts if missing).
2. Click **+ Capability → HealthKit** — required for Apple Health sync
   (steps, workouts, heart rate, resting HR, weight, sleep). The usage strings are
   already in Info.plist.
3. If the bundle ID `za.co.helm.fitorfat` is rejected as taken, append a suffix
   (e.g. `za.co.helm.fitorfat.dev`).

Plug in the iPhone (trust the Mac on the phone), select it as the run destination,
press **▶ Run**. First run only: on the phone, Settings → General → VPN & Device
Management → trust your developer certificate.

## After install

- Sign in with an existing Fit-or-Fat account.
- Allow notifications and camera when asked.
- The Apple Health permission sheet appears on first health sync — enable all read toggles.
- Verify: More → "Sync health now" should report "Synced ✓ — N data points" (N > 0).

## Known constraints

- Free Apple ID: the install expires after 7 days — re-run from Xcode to refresh.
  A paid Apple Developer account ($99/yr) or TestFlight removes this.
- `local-plugins/capacitor-health-connect` is Android-only; it is correctly ignored by
  the iOS build. Do not delete it — `npm install` needs the folder to exist.
- The HealthKit plugin (1.3.2) compiles against the stable Capacitor plugin API; if
  `pod install` or the build fails around it, capture the exact error before changing anything.
