# @learnitive/mobile-entry

Expo (React Native) shell for the Learnitive iOS/Android app. The entire
user-facing app is the existing web build rendered in a full-screen WebView;
this package only owns the native shell: WebView lifecycle, external link
handling, and (later) the native bridge for storage and OS integration.

See `plans/009-mobile-ios-expo-shell.md` for the roadmap and rationale.

## Architecture

- Milestone M0 (current): the WebView loads `https://www.learnitive.com` (or
  `EXPO_PUBLIC_LEARNITIVE_WEB_URL`). Notes persist in IndexedDB inside the app's
  WKWebView data store. Offline and Native-FS workspaces are not supported
  yet; the web app already hides the Native FS option when the File System
  Access API is unavailable.
- Native projects (`ios/`, `android/`) are generated by `expo prebuild`
  (Continuous Native Generation) and are gitignored — never commit them.
- Three app variants with separate bundle IDs install side by side:
  `com.learnitive.app.dev`, `com.learnitive.app.preview`, `com.learnitive.app`
  (selected via `APP_VARIANT`, wired in `eas.json` profiles).

## Free local testing on your own iPhone (no paid account)

Apple's free "personal team" provisioning installs the app on your own
device via Xcode; the install expires after 7 days (rebuild to renew) and
device builds must happen locally (EAS cloud device builds require the paid
program). One-time prerequisites:

1. Xcode: Settings → Accounts → add your Apple ID (creates a Personal Team).
2. iPhone: Settings → Privacy & Security → Developer Mode → on (reboots).
3. Tools: `brew install cocoapods` (and Xcode itself).

Then, with the phone connected by cable:

```bash
APP_VARIANT=development pnpm exec expo run:ios --device
```

`expo run:ios` prompts once for the signing team (pick your Personal Team;
it writes the choice into the generated project). If the install is blocked
on the phone, trust the developer in Settings → General → VPN & Device
Management. Free-provisioning caveat: Apple limits personal teams to ~10
app IDs per week, so avoid churning bundle identifiers.

## Paid setup (TestFlight, later)

1. Enroll in the Apple Developer Program
   (https://developer.apple.com/programs/enroll/).
2. Create an Expo account and install the CLI: `npm i -g eas-cli`, then
   `eas login`.
3. From this directory run `eas init` and export the printed project id as
   `EAS_PROJECT_ID` (EAS build env + local shell) — `app.config.ts` reads it.
4. First iOS build: `pnpm eas:dev`. EAS walks through creating signing
   credentials on its servers; no local Xcode signing setup is needed.

## Dev loop (no local Xcode/CocoaPods required)

1. `pnpm eas:dev` — cloud-builds a development client; install it on your
   phone from the QR code / link EAS prints.
2. `pnpm dev:client` — starts Metro; open the dev client and connect.
3. To point the shell at local web code: run the web app with
   `pnpm start --host` at the repo root, then
   `EXPO_PUBLIC_LEARNITIVE_WEB_URL=http://<your-lan-ip>:5173 pnpm dev:client`.

If Xcode + CocoaPods + an iOS simulator runtime are installed locally,
`pnpm ios` does a local prebuild + simulator run instead.

## TestFlight

```bash
pnpm eas:preview        # internal-distribution build (ad hoc)
pnpm eas:prod           # App Store build
pnpm eas:submit         # upload the latest build to App Store Connect
```

`eas submit` prompts for the App Store Connect app on first run and stores
the `ascAppId` in `eas.json`.

## Verification

- `pnpm expo-config` — resolves the final config for the current variant.
- On device: create a Browser workspace, write a note, force-quit the app,
  relaunch, confirm the note persists.
