# Building the Relentless Few mobile app (APK + iOS)

This folder is the **download drop folder** for the clan site. Everything the
public page (`/app`) serves lives here.

The app source is bundled alongside this file as
**`relentless-few-app-src-1.1.0.zip`** — a complete Expo SDK 57 / React Native
0.86 project. The compiled, installable binaries are produced from that source.

> **Why aren't the APK/IPA already here?**
> A native **Android APK** must be compiled with a JDK + Android SDK, and an
> **iOS IPA** must be compiled on macOS/Xcode. Those toolchains are not present
> on a plain web server, so the binaries are produced by **Expo's cloud build
> service (EAS Build)** — no Mac and no Android Studio required — and then
> dropped into this folder. The helper script below automates the whole thing.

---

## TL;DR — one command

On any machine with **Node.js 20+** (your laptop or the server):

```bash
# 1. unzip the source next to this folder
unzip downloads/relentless-few-app-src-1.1.0.zip -d .

# 2. build BOTH the Android APK and the iOS IPA, saved into downloads/
bash downloads/build-app.sh --dir ./relentless-few-app
```

When it finishes you will have:

```
downloads/relentless-few-1.1.0.apk     ← Android, installable
downloads/relentless-few-1.1.0.ipa     ← iOS (App Store / TestFlight)
```

Then set the links in **`/admin/app_manager.php` → Edit links** (or directly in
`updates/app_releases.json`) and the buttons on `/app` light up automatically.

---

## What each artifact is

| File | Platform | How members install it |
|------|----------|------------------------|
| `relentless-few-1.1.0.apk` | Android | Download → “Allow from this source” → Install |
| `relentless-few-1.1.0.aab` | Android (Play) | Upload to the Google Play Console |
| `relentless-few-1.1.0.ipa` | iOS | Distribute via TestFlight or the App Store |
| `relentless-few-app-src-1.1.0.zip` | — | Full source, for developers |

---

## Manual build (if you prefer to run the steps yourself)

```bash
cd relentless-few-app
npm ci
npm install -g eas-cli
eas login
eas init                                   # links the project (writes a real projectId)

# Android APK (sideload / direct download)
eas build --platform android --profile preview

# Android App Bundle (Google Play)
eas build --platform android --profile production

# iOS (App Store / TestFlight) — builds in the cloud, no Mac needed
eas build --platform ios --profile production
```

When a build finishes, EAS prints a URL. Download the artifact and save it in
this folder using the canonical names above.

### Unattended / CI builds

```bash
export EXPO_TOKEN=xxxxxxxxxxxxxxxx     # Account → Access tokens
eas build --platform android --profile preview --non-interactive --wait
```

---

## Local Android build (optional, needs a full toolchain)

If you have **JDK 17 + Android SDK** installed you can build offline:

```bash
cd relentless-few-app
npx expo prebuild --platform android
cd android && ./gradlew assembleRelease
# → android/app/build/outputs/apk/release/app-release.apk
```

iOS **cannot** be built off macOS — use EAS cloud (above) or a Mac with Xcode.

---

## Installing on the server

The source zip also contains `scripts/install-app.sh` and
`scripts/INSTALL-APP.md`, which set up Node.js, the web bundle, the universal-link
files and the optional push worker on **AlmaLinux 9 + DirectAdmin**:

```bash
sudo bash scripts/install-app.sh --domain app.relentlessfew.com
```

---

## How the site uses this folder

- Public page: **`https://relentlessfew.com/app`** (source: `app.php`).
- Links are stored in **`updates/app_releases.json`** and edited in the admin
  console under **Integrations → Mobile App**.
- The page is **file-aware**: for any `/downloads/...` link it checks whether the
  file actually exists and only enables the button when it does — so you never
  ship a broken download.

---

*Relentless Few · Est. 2010 — the lobby's worst nightmare.*
