Skip to content

armgit / ente

Public Imported from GitHub
0

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

The README fairy visits

Manav Rathi051369710014
diff --git a/mobile/native/darwin/Apps/Ensu/README.md b/mobile/native/darwin/Apps/Ensu/README.md
index 1fba60a9fe..2de6d86a2e 100644
--- a/mobile/native/darwin/Apps/Ensu/README.md
+++ b/mobile/native/darwin/Apps/Ensu/README.md
@@ -2,16 +2,13 @@
Source code for the Ensu iOS app.
-To know more about Ente, see [our main README](../../../../../README.md) or
-visit [ente.com](https://ente.com).
+To know more about Ente, see [our main README](../../../../../README.md) or visit [ente.com](https://ente.com).
## Building from source
-1. Install [Xcode](https://developer.apple.com/xcode/),
-[Rust](https://www.rust-lang.org/tools/install), and CMake (e.g.
-`brew install cmake`).
+1. Install [Xcode](https://developer.apple.com/xcode/), [Rust](https://www.rust-lang.org/tools/install), and CMake (e.g. `brew install cmake`).
-2. Generate the Rust bindings:
+2. Generate the Swift bindings:
```sh
cd rust
@@ -20,49 +17,41 @@ visit [ente.com](https://ente.com).
3. Open `Ensu.xcodeproj` in Xcode and run the `Ensu` scheme.
-That's it. From here on it's a normal iOS project.
+That's it. Apart from the `cargo codegen`, this is a normal iOS project.
> [!NOTE]
>
> Re-run `cargo codegen ensu-ios` whenever the UniFFI interface under `rust/uniffi` changes.
-#### Custom API endpoint
-
-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.
+A custom endpoint can be baked into the build via `xcodebuild ENTE_API_ENDPOINT=http://localhost:8080 ...` or by editing the user-defined `ENTE_API_ENDPOINT` build setting in the `Ensu` target.
## Terminal builds
-If you want to build from the terminal instead of Xcode,
+> [!NOTE]
+>
+> If you'd rather not open Xcode, this section is for you.
+
+Build and run on the simulator:
```sh
-xcodebuild \
- -scheme Ensu \
- -configuration Debug \
- -sdk iphonesimulator \
- -destination 'platform=iOS Simulator,name=iPhone 17' \
- SWIFT_ENABLE_EXPLICIT_MODULES=NO
+open -a Simulator
+xcodebuild -scheme Ensu -destination 'platform=iOS Simulator,name=iPhone 17'
+xcrun simctl install booted ~/Library/Developer/Xcode/DerivedData/Ensu-*/Build/Products/Debug-iphonesimulator/Ensu.app
+xcrun simctl launch booted io.ente.ensu
```
-Release archive:
+Create a release archive:
```sh
-xcodebuild \
- -scheme Ensu \
- -configuration Release \
- -sdk iphoneos \
+xcodebuild archive -scheme Ensu \
-destination 'generic/platform=iOS' \
- -archivePath build/Archive/Ensu.xcarchive \
- archive \
- SWIFT_ENABLE_EXPLICIT_MODULES=NO
+ -archivePath build/Archive/Ensu.xcarchive
```
Export an IPA from the archive:
```sh
-xcodebuild \
- -exportArchive \
+xcodebuild -exportArchive \
-archivePath build/Archive/Ensu.xcarchive \
-exportPath build/Export \
-exportOptionsPlist ExportOptions-AppStore.plist
@@ -76,8 +65,6 @@ Run the app-hosted inference integration test with these environment variables:
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
+xcodebuild test -scheme Ensu \
+ -destination 'platform=iOS Simulator,name=iPhone 17'
```
diff --git a/mobile/native/darwin/Apps/Ensu/build.sh b/mobile/native/darwin/Apps/Ensu/build.sh
deleted file mode 100755
index a267067781..0000000000
--- a/mobile/native/darwin/Apps/Ensu/build.sh
+++ /dev/null
@@ -1,290 +0,0 @@
-#!/usr/bin/env bash
-set -euo pipefail
-
-ROOT="$(cd "$(dirname "$0")" && pwd)"
-
-MODE="sim"
-DESTINATION_ID=""
-ENDPOINT=""
-ARCHIVE_PATH="$ROOT/build/Archive/Ensu.xcarchive"
-EXPORT_PATH="$ROOT/build/Export"
-EXPORT_OPTIONS_PLIST="$ROOT/ExportOptions-AppStore.plist"
-
-XCODE_EXTRA_ARGS=()
-XCODE_VERSION="$(xcodebuild -version 2>/dev/null | awk '/^Xcode / { print $2; exit }')"
-if [[ "$XCODE_VERSION" == 26* ]]; then
- XCODE_EXTRA_ARGS+=(SWIFT_ENABLE_EXPLICIT_MODULES=NO)
-fi
-
-# Run xcodebuild, capturing output to a temp log to avoid SIGPIPE with pipefail.
-# On failure, prints the last 30 lines of the log for diagnostics.
-run_xcodebuild() {
- local log
- log="$(mktemp)"
- if xcodebuild "$@" > "$log" 2>&1; then
- rm -f "$log"
- else
- local rc=$?
- echo "xcodebuild failed (exit $rc). Last 30 lines:" >&2
- tail -30 "$log" >&2
- echo >&2
- echo "Full xcodebuild log: $log" >&2
- exit $rc
- fi
-}
-
-resolve_package_dependencies() {
- echo "==> Resolving Swift package dependencies"
- run_xcodebuild \
- -resolvePackageDependencies \
- -scheme Ensu \
- "${XCODE_EXTRA_ARGS[@]}"
-}
-
-usage() {
- cat <<'EOF'
-Build Ensu Apple app.
-
-Usage:
- ./build.sh [sim|device|archive|ipa] [options]
-
-Modes:
- sim Debug build for iOS simulator (default, prefers booted iPhone)
- device Debug build for connected iOS device
- archive Release archive (.xcarchive)
- ipa Build + export IPA using ExportOptions plist
-
-Options:
- --destination-id <id> Force specific destination id (sim/device)
- --endpoint <url> Set ENTE_API_ENDPOINT for this build
- --archive-path <path> Override archive output path
- --export-path <path> Override IPA export directory (ipa mode)
- --export-options-plist <path> Override export options plist (ipa mode)
- -h, --help Show help
-
-Examples:
- ./build.sh
- ./build.sh sim
- ./build.sh device
- ./build.sh archive
- ./build.sh ipa
-EOF
-}
-
-pick_booted_simulator_id() {
- if ! command -v python3 >/dev/null 2>&1; then
- return
- fi
-
- python3 - <<'PY' 2>/dev/null
-import json
-import subprocess
-import sys
-
-try:
- out = subprocess.check_output(
- ["xcrun", "simctl", "list", "devices", "booted", "--json"],
- stderr=subprocess.DEVNULL,
- text=True,
- )
-except Exception:
- sys.exit(0)
-
-try:
- data = json.loads(out)
-except Exception:
- sys.exit(0)
-
-booted = []
-for runtime_devices in data.get("devices", {}).values():
- for device in runtime_devices:
- if device.get("state") != "Booted":
- continue
- if device.get("isAvailable") is False:
- continue
- name = device.get("name", "")
- udid = device.get("udid", "")
- if not udid:
- continue
- booted.append((name, udid))
-
-if not booted:
- sys.exit(0)
-
-booted.sort(key=lambda item: (0 if "iphone" in item[0].lower() else 1, item[0]))
-print(booted[0][1])
-PY
-}
-
-pick_destination_id() {
- local platform="$1"
- local prefer_iphone="${2:-0}"
- local destinations
-
- destinations="$(xcodebuild -scheme Ensu -showdestinations 2>/dev/null \
- | sed -n "s/.*platform:${platform},.*id:\([^,}]*\).*, name:\([^}]*\).*/\1|\2/p" \
- | grep -v '^dvtdevice-' || true)"
-
- if [[ -z "$destinations" ]]; then
- return
- fi
-
- if [[ "$prefer_iphone" == "1" ]]; then
- local iphone_id
- iphone_id="$(printf "%s\n" "$destinations" | awk -F'|' '/iPhone/ { print $1; exit }')"
- if [[ -n "$iphone_id" ]]; then
- echo "$iphone_id"
- return
- fi
- fi
-
- printf "%s\n" "$destinations" | head -n 1 | cut -d'|' -f1
-}
-
-while [[ $# -gt 0 ]]; do
- case "$1" in
- sim|device|archive|ipa)
- MODE="$1"
- shift
- ;;
- --destination-id)
- DESTINATION_ID="${2:-}"
- if [[ -z "$DESTINATION_ID" ]]; then
- echo "Missing value for --destination-id" >&2
- exit 1
- fi
- shift 2
- ;;
- --endpoint)
- ENDPOINT="${2:-}"
- if [[ -z "$ENDPOINT" ]]; then
- echo "Missing value for --endpoint" >&2
- exit 1
- fi
- shift 2
- ;;
- --archive-path)
- ARCHIVE_PATH="${2:-}"
- if [[ -z "$ARCHIVE_PATH" ]]; then
- echo "Missing value for --archive-path" >&2
- exit 1
- fi
- shift 2
- ;;
- --export-path)
- EXPORT_PATH="${2:-}"
- if [[ -z "$EXPORT_PATH" ]]; then
- echo "Missing value for --export-path" >&2
- exit 1
- fi
- shift 2
- ;;
- --export-options-plist)
- EXPORT_OPTIONS_PLIST="${2:-}"
- if [[ -z "$EXPORT_OPTIONS_PLIST" ]]; then
- echo "Missing value for --export-options-plist" >&2
- exit 1
- fi
- shift 2
- ;;
- -h|--help)
- usage
- exit 0
- ;;
- *)
- echo "Unknown argument: $1" >&2
- usage
- exit 1
- ;;
- esac
-done
-
-cd "$ROOT"
-
-if [[ -n "$ENDPOINT" ]]; then
- export ENTE_API_ENDPOINT="$ENDPOINT"
-fi
-
-resolve_package_dependencies
-
-build_archive() {
- mkdir -p "$(dirname "$ARCHIVE_PATH")"
- echo "==> Building Release archive"
- run_xcodebuild \
- -scheme Ensu \
- -configuration Release \
- -sdk iphoneos \
- -destination 'generic/platform=iOS' \
- -archivePath "$ARCHIVE_PATH" \
- archive \
- "${XCODE_EXTRA_ARGS[@]}"
- echo "βœ… Archive: $ARCHIVE_PATH"
-}
-
-case "$MODE" in
- sim)
- if [[ -z "$DESTINATION_ID" ]]; then
- DESTINATION_ID="$(pick_booted_simulator_id)"
- fi
- if [[ -z "$DESTINATION_ID" ]]; then
- DESTINATION_ID="$(pick_destination_id 'iOS Simulator' 1)"
- fi
- if [[ -z "$DESTINATION_ID" ]]; then
- echo "No iOS Simulator destination found. Open Simulator.app once and retry." >&2
- exit 1
- fi
-
- echo "==> Building Debug for simulator (id=$DESTINATION_ID)"
- run_xcodebuild \
- -scheme Ensu \
- -configuration Debug \
- -sdk iphonesimulator \
- -destination "id=$DESTINATION_ID" \
- "${XCODE_EXTRA_ARGS[@]}"
- ;;
- device)
- if [[ -z "$DESTINATION_ID" ]]; then
- DESTINATION_ID="$(pick_destination_id 'iOS' 1)"
- fi
- if [[ -z "$DESTINATION_ID" ]]; then
- echo "No connected iOS device found. Connect a device or pass --destination-id." >&2
- exit 1
- fi
-
- echo "==> Building Debug for device (id=$DESTINATION_ID)"
- run_xcodebuild \
- -scheme Ensu \
- -configuration Debug \
- -sdk iphoneos \
- -destination "id=$DESTINATION_ID" \
- "${XCODE_EXTRA_ARGS[@]}"
- ;;
- archive)
- build_archive
- ;;
- ipa)
- if [[ ! -f "$EXPORT_OPTIONS_PLIST" ]]; then
- echo "Export options plist not found: $EXPORT_OPTIONS_PLIST" >&2
- exit 1
- fi
-
- build_archive
-
- mkdir -p "$EXPORT_PATH"
- echo "==> Exporting IPA"
- run_xcodebuild \
- -exportArchive \
- -archivePath "$ARCHIVE_PATH" \
- -exportPath "$EXPORT_PATH" \
- -exportOptionsPlist "$EXPORT_OPTIONS_PLIST"
-
- IPA_PATH="$(find "$EXPORT_PATH" -maxdepth 1 -type f -name '*.ipa' | head -n 1 || true)"
- if [[ -n "$IPA_PATH" ]]; then
- echo "βœ… IPA: $IPA_PATH"
- else
- echo "βœ… Exported to: $EXPORT_PATH"
- fi
- ;;
-esac
-
-echo "βœ… Done"
diff --git a/mobile/native/darwin/Apps/Ensu/run.sh b/mobile/native/darwin/Apps/Ensu/run.sh
deleted file mode 100755
index 5fb08fcb9e..0000000000
--- a/mobile/native/darwin/Apps/Ensu/run.sh
+++ /dev/null
@@ -1,192 +0,0 @@
-#!/usr/bin/env bash
-set -euo pipefail
-
-ROOT="$(cd "$(dirname "$0")" && pwd)"
-APP_BUNDLE_ID="io.ente.ensu"
-
-DESTINATION_ID=""
-SKIP_BUILD=0
-ENDPOINT=""
-
-usage() {
- cat <<'EOF'
-Build + install + launch Ensu on iOS Simulator.
-
-Usage:
- ./run.sh [options]
-
-Options:
- --destination-id <id> Use specific simulator id
- --skip-build Skip build step
- --endpoint <url> Set ENTE_API_ENDPOINT for build
- -h, --help Show help
-
-Examples:
- ./run.sh # prefers currently booted iPhone simulator
- ./run.sh --destination-id <SIMULATOR_UUID>
-EOF
-}
-
-pick_booted_simulator_id() {
- if ! command -v python3 >/dev/null 2>&1; then
- return
- fi
-
- python3 - <<'PY' 2>/dev/null
-import json
-import subprocess
-import sys
-
-try:
- out = subprocess.check_output(
- ["xcrun", "simctl", "list", "devices", "booted", "--json"],
- stderr=subprocess.DEVNULL,
- text=True,
- )
-except Exception:
- sys.exit(0)
-
-try:
- data = json.loads(out)
-except Exception:
- sys.exit(0)
-
-booted = []
-for runtime_devices in data.get("devices", {}).values():
- for device in runtime_devices:
- if device.get("state") != "Booted":
- continue
- if device.get("isAvailable") is False:
- continue
- name = device.get("name", "")
- udid = device.get("udid", "")
- if not udid:
- continue
- booted.append((name, udid))
-
-if not booted:
- sys.exit(0)
-
-booted.sort(key=lambda item: (0 if "iphone" in item[0].lower() else 1, item[0]))
-print(booted[0][1])
-PY
-}
-
-pick_simulator_id() {
- local destinations
-
- destinations="$(xcodebuild -scheme Ensu -showdestinations 2>/dev/null \
- | sed -n 's/.*platform:iOS Simulator,.*id:\([^,}]*\).*, name:\([^}]*\).*/\1|\2/p' \
- | grep -v '^dvtdevice-' || true)"
-
- if [[ -z "$destinations" ]]; then
- return
- fi
-
- local iphone_id
- iphone_id="$(printf "%s\n" "$destinations" | awk -F'|' '/iPhone/ { print $1; exit }')"
- if [[ -n "$iphone_id" ]]; then
- echo "$iphone_id"
- return
- fi
-
- printf "%s\n" "$destinations" | head -n 1 | cut -d'|' -f1
-}
-
-app_path_for_destination() {
- xcodebuild \
- -scheme Ensu \
- -configuration Debug \
- -sdk iphonesimulator \
- -destination "id=$DESTINATION_ID" \
- -showBuildSettings 2>/dev/null \
- | awk '
- /^Build settings for action build and target Ensu:/ { in_target=1; next }
- /^Build settings for action build and target / { in_target=0 }
- in_target && $1 == "TARGET_BUILD_DIR" { build_dir=$3 }
- in_target && $1 == "WRAPPER_NAME" { wrapper_name=$3 }
- END {
- if (build_dir != "" && wrapper_name != "") {
- print build_dir "/" wrapper_name
- }
- }
- '
-}
-
-while [[ $# -gt 0 ]]; do
- case "$1" in
- --destination-id)
- DESTINATION_ID="${2:-}"
- if [[ -z "$DESTINATION_ID" ]]; then
- echo "Missing value for --destination-id" >&2
- exit 1
- fi
- shift 2
- ;;
- --skip-build)
- SKIP_BUILD=1
- shift
- ;;
- --endpoint)
- ENDPOINT="${2:-}"
- if [[ -z "$ENDPOINT" ]]; then
- echo "Missing value for --endpoint" >&2
- exit 1
- fi
- shift 2
- ;;
- -h|--help)
- usage
- exit 0
- ;;
- *)
- echo "Unknown argument: $1" >&2
- usage
- exit 1
- ;;
- esac
-done
-
-cd "$ROOT"
-
-if [[ -z "$DESTINATION_ID" ]]; then
- DESTINATION_ID="$(pick_booted_simulator_id)"
-fi
-if [[ -z "$DESTINATION_ID" ]]; then
- DESTINATION_ID="$(pick_simulator_id)"
-fi
-if [[ -z "$DESTINATION_ID" ]]; then
- echo "No iOS Simulator destination found. Open Simulator.app once and retry." >&2
- exit 1
-fi
-
-if [[ "$SKIP_BUILD" -eq 0 ]]; then
- BUILD_ARGS=(sim --destination-id "$DESTINATION_ID")
- if [[ -n "$ENDPOINT" ]]; then
- BUILD_ARGS+=(--endpoint "$ENDPOINT")
- fi
- "$ROOT/build.sh" "${BUILD_ARGS[@]}"
-fi
-
-APP_PATH="$(app_path_for_destination)"
-if [[ -z "$APP_PATH" ]]; then
- echo "Could not determine built app path from Xcode build settings." >&2
- exit 1
-fi
-
-if [[ ! -d "$APP_PATH" ]]; then
- echo "App not found: $APP_PATH" >&2
- echo "Run ./build.sh sim first." >&2
- exit 1
-fi
-
-echo "==> Booting simulator $DESTINATION_ID"
-xcrun simctl boot "$DESTINATION_ID" >/dev/null 2>&1 || true
-
-echo "==> Installing app"
-xcrun simctl install "$DESTINATION_ID" "$APP_PATH"
-
-echo "==> Launching $APP_BUNDLE_ID"
-xcrun simctl launch "$DESTINATION_ID" "$APP_BUNDLE_ID"
-
-echo "βœ… Ensu launched on iOS Simulator"