# Anime 2.5D Rig for macOS and iPhone

This project wraps the exact Anime 2.5D WebGL renderer in a native `WKWebView`. The Mac app uses the full desktop controls; the iPhone app adds `?compact=1`, so the same renderer presents the character picker and only the essential tracking drawers. The iPhone renders locally and works without a Mac.

## Build on a Mac

Requirements: macOS 14 or newer, Xcode 16 or newer, and [XcodeGen](https://github.com/yonaskolb/XcodeGen).

```sh
brew install xcodegen
cd Anime25DRigApple
sh ./sync_web.sh https://anime25d-rig.pages.dev
xcodegen generate
open Anime25DRigApple.xcodeproj
```

`sync_web.sh` downloads a snapshot into `Web/`; Xcode then embeds that snapshot in each app. For a reproducible release, pass the unique URL from a specific Cloudflare Pages deployment instead of the moving production URL. The apps never execute newly deployed JavaScript after they are built.

For a Codex handoff on the Mac, point it at this guide and ask it to run the commands above, then verify both unsigned local builds before opening Xcode:

```sh
xcodebuild -project Anime25DRigApple.xcodeproj -scheme Anime25DRig-macOS -configuration Debug -derivedDataPath .build/macos CODE_SIGNING_ALLOWED=NO build
xcodebuild -project Anime25DRigApple.xcodeproj -scheme Anime25DRig-iOS -sdk iphonesimulator -destination 'generic/platform=iOS Simulator' -configuration Debug -derivedDataPath .build/ios CODE_SIGNING_ALLOWED=NO build
```

## Run the Mac app

1. Select the `Anime25DRig-macOS` scheme and **My Mac**.
2. In **Signing & Capabilities**, select your Apple development team.
3. Press Run. Allow camera, microphone, and local-network access when requested.

The hardened, sandboxed app has only camera, audio input, user-selected read-only files, and client/server network entitlements.

## Run the iPhone app

1. Connect an iPhone, enable Developer Mode, and trust the Mac.
2. Select the `Anime25DRig-iOS` scheme and that iPhone.
3. Select your team; change the bundle identifier if your team does not own the default one.
4. Press Run and allow camera, microphone, and local-network access.

Use a physical iPhone for face tracking; Simulator camera behavior is not representative. The iPhone can select and run a character by itself. When both apps are on the same local network, open the Mac app first and then the iPhone app: the phone discovers the Mac automatically and synchronizes model IDs and essential control values. Camera frames and microphone audio never leave the device. The Multipeer Connectivity session requires encryption.

## Cloudflare's role

Cloudflare Pages hosts the public browser version, the model catalog/content, this source kit, and build instructions. Native App Store code must be self-contained, so `sync_web.sh` copies the web engine into the signed app at build time. Finalized PSD files may still be fetched as content; keep model URLs HTTPS and configure CORS on Pages.

## Ship through Apple

- Join the Apple Developer Program for TestFlight, App Store distribution, Developer ID signing, and notarization.
- Add final 1024 px artwork to an `AppIcon` asset catalog before archiving.
- Archive each scheme in Xcode, validate, then distribute the iPhone archive through TestFlight/App Store Connect. Distribute the Mac archive through the Mac App Store or sign with Developer ID and notarize it.
- Publish a privacy-policy URL explaining that face landmarks and microphone level are processed on-device and are not collected.
- Test camera, microphone, local-network permission denial, offline launch, and standalone iPhone operation before review.
