Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Simplify Ensu iOS setup flow

Manav Rathi496b6e94ca1d
diff --git a/mobile/native/darwin/Apps/Ensu/Ensu.xcodeproj/project.pbxproj b/mobile/native/darwin/Apps/Ensu/Ensu.xcodeproj/project.pbxproj
index e57e33378c..5fadf10fd8 100644
--- a/mobile/native/darwin/Apps/Ensu/Ensu.xcodeproj/project.pbxproj
+++ b/mobile/native/darwin/Apps/Ensu/Ensu.xcodeproj/project.pbxproj
@@ -237,18 +237,7 @@
"$(TARGET_TEMP_DIR)/ensu_rust/libdb.a",
"$(TARGET_TEMP_DIR)/ensu_rust/libsync.a",
"$(TARGET_TEMP_DIR)/ensu_rust/libinference.a",
- "$(SRCROOT)/Ensu/Generated/core.swift",
- "$(SRCROOT)/Ensu/Generated/coreFFI.h",
- "$(SRCROOT)/Ensu/Generated/coreFFI.modulemap",
- "$(SRCROOT)/Ensu/Generated/db.swift",
- "$(SRCROOT)/Ensu/Generated/dbFFI.h",
- "$(SRCROOT)/Ensu/Generated/dbFFI.modulemap",
- "$(SRCROOT)/Ensu/Generated/sync.swift",
- "$(SRCROOT)/Ensu/Generated/syncFFI.h",
- "$(SRCROOT)/Ensu/Generated/syncFFI.modulemap",
- "$(SRCROOT)/Ensu/Generated/inference.swift",
- "$(SRCROOT)/Ensu/Generated/inferenceFFI.h",
- "$(SRCROOT)/Ensu/Generated/inferenceFFI.modulemap",
+ "$(SRCROOT)/Ensu/Generated/EndpointConfig.swift",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
diff --git a/mobile/native/darwin/Apps/Ensu/README.md b/mobile/native/darwin/Apps/Ensu/README.md
index ddb166b918..1fba60a9fe 100644
--- a/mobile/native/darwin/Apps/Ensu/README.md
+++ b/mobile/native/darwin/Apps/Ensu/README.md
@@ -1,102 +1,66 @@
-# Ensu Apple Platforms
+# Ensu for iOS
-## Build (Terminal)
+Source code for the Ensu iOS app.
-All commands below assume you run them from `darwin/Apps/Ensu`.
+To know more about Ente, see [our main README](../../../../../README.md) or
+visit [ente.com](https://ente.com).
-## Quick scripts
+## Building from source
-```bash
-./setup-mac.sh # Check prerequisites and resolve packages
-./build.sh # Debug build for iOS simulator (prefers booted iPhone)
-./build.sh device # Debug build for connected iOS device
-./build.sh archive # Release archive (.xcarchive)
-./build.sh ipa # Release IPA export (uses ExportOptions-AppStore.plist)
-./run.sh # Build + install + launch on iOS simulator (prefers booted iPhone)
-```
-
-Helpful flags:
+1. Install [Xcode](https://developer.apple.com/xcode/),
+[Rust](https://www.rust-lang.org/tools/install), and CMake (e.g.
+`brew install cmake`).
-- `--destination-id <id>` to force a specific simulator/device
-- `--endpoint <url>` to set `ENTE_API_ENDPOINT`
-- `--archive-path`, `--export-path`, `--export-options-plist` for release flows
-- `--skip-build` for `run.sh`
+2. Generate the Rust bindings:
-Run `./build.sh --help` or `./run.sh --help` for full options.
+ ```sh
+ cd rust
+ cargo codegen ensu-ios
+ ```
-The helper scripts default release outputs to `build/Archive/Ensu.xcarchive` and `build/Export/`
-unless you override them.
+3. Open `Ensu.xcodeproj` in Xcode and run the `Ensu` scheme.
-cmake is a prerequisite (e.g. `brew install cmake`).
+That's it. From here on it's a normal iOS project.
-## Generated bindings & dependencies
+> [!NOTE]
+>
+> Re-run `cargo codegen ensu-ios` whenever the UniFFI interface under `rust/uniffi` changes.
-- On a fresh checkout, from the repo root run the repo-local codegen step before any Xcode build:
+#### Custom API endpoint
-```bash
-cd rust
-cargo codegen ensu-ios
-```
+To connect to a custom endpoint, define
+`ENTE_API_ENDPOINT` either via `xcodebuild ENTE_API_ENDPOINT=http://localhost:8080 ...` or by editing the user-defined `ENTE_API_ENDPOINT` build setting in the
+`Ensu` target.
-- SwiftMath is fetched via SwiftPM (`https://github.com/mgriebling/SwiftMath.git`).
-- UniFFI Swift bindings are generated locally and gitignored:
- - `Ensu/Generated/core*`, `Ensu/Generated/db*`, `Ensu/Generated/sync*`, `Ensu/Generated/inference*`
+## Terminal builds
-The Xcode build script (`scripts/build-rust.sh`) builds the Rust static libs directly into
-`$(TARGET_TEMP_DIR)/ensu_rust` and consumes the generated `core`, `db`, `sync`, and `inference`
-Swift bindings from `Ensu/Generated/`. It does not generate bindings or install tools.
+If you want to build from the terminal instead of Xcode,
-### Debug Build (Simulator)
-```bash
-cd darwin/Apps/Ensu
+```sh
xcodebuild \
-scheme Ensu \
-configuration Debug \
-sdk iphonesimulator \
- -destination 'platform=iOS Simulator,name=iPhone 17'
-```
-
-## Tests
-
-Run the app-hosted inference integration test from Terminal with `TEST_RUNNER_...` environment
-variables so they reach the XCTest runner process:
-
-```bash
-cd darwin/Apps/Ensu
-TEST_RUNNER_ENSU_TEST_MODEL=/path/to/model.gguf \
-TEST_RUNNER_ENSU_TEST_MMPROJ=/path/to/mmproj.gguf \
-TEST_RUNNER_ENSU_TEST_IMAGE=/path/to/image.png \
-xcodebuild test \
- -scheme Ensu \
-destination 'platform=iOS Simulator,name=iPhone 17' \
SWIFT_ENABLE_EXPLICIT_MODULES=NO
```
-### Debug Build (Device)
-```bash
-cd darwin/Apps/Ensu
-xcodebuild \
- -scheme Ensu \
- -configuration Debug \
- -sdk iphoneos \
- -destination 'generic/platform=iOS'
-```
+Release archive:
-### Release Build (Archive)
-```bash
-cd darwin/Apps/Ensu
+```sh
xcodebuild \
-scheme Ensu \
-configuration Release \
-sdk iphoneos \
-destination 'generic/platform=iOS' \
-archivePath build/Archive/Ensu.xcarchive \
- archive
+ archive \
+ SWIFT_ENABLE_EXPLICIT_MODULES=NO
```
-### Release IPA (App Store)
-```bash
-cd darwin/Apps/Ensu
+Export an IPA from the archive:
+
+```sh
xcodebuild \
-exportArchive \
-archivePath build/Archive/Ensu.xcarchive \
@@ -104,37 +68,16 @@ xcodebuild \
-exportOptionsPlist ExportOptions-AppStore.plist
```
-## Installation (Terminal)
-
-### Debug (Simulator)
-```bash
-cd darwin/Apps/Ensu
-./run.sh
-```
-
-### Debug (Physical Device)
-```bash
-cd darwin/Apps/Ensu
-./build.sh device --destination-id <DEVICE_UDID>
-```
-
-Install the built app from Xcode or `devicectl` using the product under Xcode `DerivedData`.
-
-### Release (IPA)
-Install the exported IPA via Apple Configurator or TestFlight after `xcodebuild -exportArchive`.
-
-Note: App Store IPA export requires valid distribution signing certificate/profile on this machine.
-
-## Custom API Endpoint
+### Tests
-Set the endpoint at build time using `ENTE_API_ENDPOINT`. If it is not set, the app defaults to `https://api.ente.io`.
+Run the app-hosted inference integration test with these environment variables:
-```bash
-cd darwin/Apps/Ensu
-ENTE_API_ENDPOINT="https://your-endpoint.example" \
- xcodebuild \
+```sh
+TEST_RUNNER_ENSU_TEST_MODEL=/path/to/model.gguf \
+TEST_RUNNER_ENSU_TEST_MMPROJ=/path/to/mmproj.gguf \
+TEST_RUNNER_ENSU_TEST_IMAGE=/path/to/image.png \
+xcodebuild test \
-scheme Ensu \
- -configuration Debug \
- -sdk iphonesimulator \
- -destination 'platform=iOS Simulator,name=iPhone 17'
+ -destination 'platform=iOS Simulator,name=iPhone 17' \
+ SWIFT_ENABLE_EXPLICIT_MODULES=NO
```
diff --git a/mobile/native/darwin/Apps/Ensu/setup-mac.sh b/mobile/native/darwin/Apps/Ensu/setup-mac.sh
deleted file mode 100755
index d4cb704d4c..0000000000
--- a/mobile/native/darwin/Apps/Ensu/setup-mac.sh
+++ /dev/null
@@ -1,161 +0,0 @@
-#!/usr/bin/env bash
-set -euo pipefail
-
-# Bootstraps the local macOS prerequisites needed to archive Ensu.
-#
-# This script intentionally stops before provisioning and TestFlight upload.
-# It covers the setup steps we had to take locally to make `archive` work:
-# 1. Ensure required local developer tools are installed.
-# 2. Ensure the required Rust Apple targets are installed.
-# 3. Ensure the generated UniFFI Swift bindings already exist.
-# 4. Resolve Swift package dependencies for the Xcode project.
-# 5. Print the archive command to run next.
-#
-# Usage:
-# ./setup-mac.sh
-# ./setup-mac.sh --archive
-
-ROOT="$(cd "$(dirname "$0")" && pwd)"
-ARCHIVE_PATH="$ROOT/build/Archive/Ensu.xcarchive"
-
-ARCHIVE_AFTER_SETUP=0
-
-while [[ $# -gt 0 ]]; do
- case "$1" in
- --archive)
- ARCHIVE_AFTER_SETUP=1
- shift
- ;;
- -h|--help)
- cat <<'EOF'
-Prepare a Mac to archive Ensu locally.
-
-Usage:
- ./setup-mac.sh [--archive]
-
-Options:
- --archive Run the archive command after setup succeeds.
-EOF
- exit 0
- ;;
- *)
- echo "Unknown argument: $1" >&2
- exit 1
- ;;
- esac
-done
-
-print_step() {
- echo
- echo "==> $1"
-}
-
-require_command() {
- local name="$1"
- local hint="${2:-}"
- if command -v "$name" >/dev/null 2>&1; then
- return
- fi
-
- echo "Missing required command: $name" >&2
- if [[ -n "$hint" ]]; then
- echo "$hint" >&2
- fi
- exit 1
-}
-
-require_rust_target() {
- local target="$1"
- if rustup target list --installed | grep -qx "$target"; then
- return
- fi
-
- echo "Missing required Rust target: $target" >&2
- echo "Install Apple targets with:" >&2
- echo " rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios" >&2
- exit 1
-}
-
-require_generated_bindings() {
- local generated_dir="$ROOT/Ensu/Generated"
-
- for binding in \
- "$generated_dir/core.swift" \
- "$generated_dir/coreFFI.h" \
- "$generated_dir/coreFFI.modulemap" \
- "$generated_dir/db.swift" \
- "$generated_dir/dbFFI.h" \
- "$generated_dir/dbFFI.modulemap" \
- "$generated_dir/sync.swift" \
- "$generated_dir/syncFFI.h" \
- "$generated_dir/syncFFI.modulemap" \
- "$generated_dir/inference.swift" \
- "$generated_dir/inferenceFFI.h" \
- "$generated_dir/inferenceFFI.modulemap"; do
- if [[ ! -f "$binding" ]]; then
- echo "Missing generated UniFFI Swift bindings under $generated_dir" >&2
- echo "Run the repo-local codegen step first:" >&2
- echo " cd \"$ROOT/../../../../../rust\"" >&2
- echo " cargo codegen ensu-ios" >&2
- exit 1
- fi
- done
-}
-
-print_step "Checking required local tools"
-require_command xcodebuild "Install Xcode and Xcode command line tools."
-require_command cargo "Install Rust and ensure cargo is on PATH."
-require_command rustup "Install rustup and ensure it is on PATH."
-require_command cmake "Install CMake, for example with 'brew install cmake'."
-require_command lipo "Install Xcode command line tools and ensure lipo is on PATH."
-
-print_step "Checking required Rust Apple targets"
-require_rust_target aarch64-apple-ios
-require_rust_target aarch64-apple-ios-sim
-require_rust_target x86_64-apple-ios
-print_step "Checking generated UniFFI Swift bindings"
-require_generated_bindings
-print_step "Resolving Swift package dependencies"
-(
- cd "$ROOT"
- xcodebuild \
- -resolvePackageDependencies \
- -scheme Ensu
-)
-
-print_step "Setup complete"
-cat <<EOF
-Local archive prerequisites are ready.
-
-Archive command:
- cd "$ROOT"
- xcodebuild \\
- -scheme Ensu \\
- -configuration Release \\
- -sdk iphoneos \\
- -destination 'generic/platform=iOS' \\
- -archivePath $ARCHIVE_PATH \\
- archive
-
-Notes:
- - If the generated Swift bindings are missing, run:
- cd "$ROOT/../../../../../rust"
- cargo codegen ensu-ios
- - Provisioning/TestFlight export is intentionally not handled here.
- - If Xcode still shows missing package products, run:
- File > Packages > Resolve Package Versions
-EOF
-
-if [[ "$ARCHIVE_AFTER_SETUP" == "1" ]]; then
- print_step "Archiving Ensu"
- (
- cd "$ROOT"
- xcodebuild \
- -scheme Ensu \
- -configuration Release \
- -sdk iphoneos \
- -destination 'generic/platform=iOS' \
- -archivePath "$ARCHIVE_PATH" \
- archive
- )
-fi