Skip to content

armgit / ente

Public Imported from GitHub
0

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

Simplify Ensu Apple local build flow

Manav Rathi571e3cd2748d
diff --git a/mobile/native/darwin/Apps/Ensu/.gitignore b/mobile/native/darwin/Apps/Ensu/.gitignore
index 567609b123..449abd8ef0 100644
--- a/mobile/native/darwin/Apps/Ensu/.gitignore
+++ b/mobile/native/darwin/Apps/Ensu/.gitignore
@@ -1 +1,2 @@
+# Local Apple release artifacts.
build/
diff --git a/mobile/native/darwin/Apps/Ensu/README.md b/mobile/native/darwin/Apps/Ensu/README.md
index ac0f814e2b..56b5d410b5 100644
--- a/mobile/native/darwin/Apps/Ensu/README.md
+++ b/mobile/native/darwin/Apps/Ensu/README.md
@@ -24,6 +24,9 @@ Helpful flags:
Run `./build.sh --help` or `./run.sh --help` for full options.
+The helper scripts default release outputs to `build/Archive/Ensu.xcarchive` and `build/Export/`
+unless you override them.
+
## Generated bindings & dependencies
- SwiftMath is fetched via SwiftPM (`https://github.com/mgriebling/SwiftMath.git`).
@@ -38,12 +41,10 @@ Swift bindings into `Ensu/Generated/` as part of the build.
```bash
cd darwin/Apps/Ensu
xcodebuild \
- -project Ensu.xcodeproj \
-scheme Ensu \
-configuration Debug \
-sdk iphonesimulator \
- -destination 'platform=iOS Simulator,name=iPhone 15' \
- -derivedDataPath build
+ -destination 'platform=iOS Simulator,name=iPhone 17'
```
## Tests
@@ -57,7 +58,6 @@ 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 \
- -project Ensu.xcodeproj \
-scheme Ensu \
-destination 'platform=iOS Simulator,name=iPhone 17' \
SWIFT_ENABLE_EXPLICIT_MODULES=NO
@@ -67,19 +67,16 @@ xcodebuild test \
```bash
cd darwin/Apps/Ensu
xcodebuild \
- -project Ensu.xcodeproj \
-scheme Ensu \
-configuration Debug \
-sdk iphoneos \
- -destination 'generic/platform=iOS' \
- -derivedDataPath build
+ -destination 'generic/platform=iOS'
```
### Release Build (Archive)
```bash
cd darwin/Apps/Ensu
xcodebuild \
- -project Ensu.xcodeproj \
-scheme Ensu \
-configuration Release \
-sdk iphoneos \
@@ -103,20 +100,17 @@ xcodebuild \
### Debug (Simulator)
```bash
cd darwin/Apps/Ensu
-xcrun simctl boot "iPhone 15" || true
-xcrun simctl install booted build/Build/Products/Debug-iphonesimulator/Ensu.app
-xcrun simctl launch booted io.ente.ensu
+./run.sh
```
### Debug (Physical Device)
```bash
cd darwin/Apps/Ensu
-xcrun devicectl device list
-xcrun devicectl device install app \
- --device <DEVICE_UDID> \
- build/Build/Products/Debug-iphoneos/Ensu.app
+./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`.
@@ -130,10 +124,8 @@ Set the endpoint at build time using `ENTE_API_ENDPOINT`. If it is not set, the
cd darwin/Apps/Ensu
ENTE_API_ENDPOINT="https://your-endpoint.example" \
xcodebuild \
- -project Ensu.xcodeproj \
-scheme Ensu \
-configuration Debug \
-sdk iphonesimulator \
- -destination 'platform=iOS Simulator,name=iPhone 15' \
- -derivedDataPath build
+ -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
index 01ddd3d8fc..a267067781 100755
--- a/mobile/native/darwin/Apps/Ensu/build.sh
+++ b/mobile/native/darwin/Apps/Ensu/build.sh
@@ -2,15 +2,12 @@
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
-PROJECT="Ensu.xcodeproj"
-SCHEME="Ensu"
-DERIVED_DATA_PATH="$ROOT/build"
MODE="sim"
DESTINATION_ID=""
ENDPOINT=""
-ARCHIVE_PATH="$DERIVED_DATA_PATH/Archive/Ensu.xcarchive"
-EXPORT_PATH="$DERIVED_DATA_PATH/Export"
+ARCHIVE_PATH="$ROOT/build/Archive/Ensu.xcarchive"
+EXPORT_PATH="$ROOT/build/Export"
EXPORT_OPTIONS_PLIST="$ROOT/ExportOptions-AppStore.plist"
XCODE_EXTRA_ARGS=()
@@ -40,9 +37,7 @@ resolve_package_dependencies() {
echo "==> Resolving Swift package dependencies"
run_xcodebuild \
-resolvePackageDependencies \
- -project "$PROJECT" \
- -scheme "$SCHEME" \
- -derivedDataPath "$DERIVED_DATA_PATH" \
+ -scheme Ensu \
"${XCODE_EXTRA_ARGS[@]}"
}
@@ -126,7 +121,7 @@ pick_destination_id() {
local prefer_iphone="${2:-0}"
local destinations
- destinations="$(xcodebuild -project "$PROJECT" -scheme "$SCHEME" -showdestinations 2>/dev/null \
+ destinations="$(xcodebuild -scheme Ensu -showdestinations 2>/dev/null \
| sed -n "s/.*platform:${platform},.*id:\([^,}]*\).*, name:\([^}]*\).*/\1|\2/p" \
| grep -v '^dvtdevice-' || true)"
@@ -216,8 +211,7 @@ build_archive() {
mkdir -p "$(dirname "$ARCHIVE_PATH")"
echo "==> Building Release archive"
run_xcodebuild \
- -project "$PROJECT" \
- -scheme "$SCHEME" \
+ -scheme Ensu \
-configuration Release \
-sdk iphoneos \
-destination 'generic/platform=iOS' \
@@ -242,12 +236,10 @@ case "$MODE" in
echo "==> Building Debug for simulator (id=$DESTINATION_ID)"
run_xcodebuild \
- -project "$PROJECT" \
- -scheme "$SCHEME" \
+ -scheme Ensu \
-configuration Debug \
-sdk iphonesimulator \
-destination "id=$DESTINATION_ID" \
- -derivedDataPath "$DERIVED_DATA_PATH" \
"${XCODE_EXTRA_ARGS[@]}"
;;
device)
@@ -261,12 +253,10 @@ case "$MODE" in
echo "==> Building Debug for device (id=$DESTINATION_ID)"
run_xcodebuild \
- -project "$PROJECT" \
- -scheme "$SCHEME" \
+ -scheme Ensu \
-configuration Debug \
-sdk iphoneos \
-destination "id=$DESTINATION_ID" \
- -derivedDataPath "$DERIVED_DATA_PATH" \
"${XCODE_EXTRA_ARGS[@]}"
;;
archive)
diff --git a/mobile/native/darwin/Apps/Ensu/run.sh b/mobile/native/darwin/Apps/Ensu/run.sh
index 72dda55ade..5fb08fcb9e 100755
--- a/mobile/native/darwin/Apps/Ensu/run.sh
+++ b/mobile/native/darwin/Apps/Ensu/run.sh
@@ -3,7 +3,6 @@ set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
APP_BUNDLE_ID="io.ente.ensu"
-APP_PATH="$ROOT/build/Build/Products/Debug-iphonesimulator/Ensu.app"
DESTINATION_ID=""
SKIP_BUILD=0
@@ -76,7 +75,7 @@ PY
pick_simulator_id() {
local destinations
- destinations="$(xcodebuild -project Ensu.xcodeproj -scheme Ensu -showdestinations 2>/dev/null \
+ destinations="$(xcodebuild -scheme Ensu -showdestinations 2>/dev/null \
| sed -n 's/.*platform:iOS Simulator,.*id:\([^,}]*\).*, name:\([^}]*\).*/\1|\2/p' \
| grep -v '^dvtdevice-' || true)"
@@ -94,6 +93,26 @@ pick_simulator_id() {
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)
@@ -149,6 +168,12 @@ if [[ "$SKIP_BUILD" -eq 0 ]]; then
"$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
diff --git a/mobile/native/darwin/Apps/Ensu/setup-mac.sh b/mobile/native/darwin/Apps/Ensu/setup-mac.sh
index 048b4f2101..8633147a4e 100755
--- a/mobile/native/darwin/Apps/Ensu/setup-mac.sh
+++ b/mobile/native/darwin/Apps/Ensu/setup-mac.sh
@@ -16,10 +16,7 @@ set -euo pipefail
# ./setup-mac.sh --archive
ROOT="$(cd "$(dirname "$0")" && pwd)"
-PROJECT="Ensu.xcodeproj"
-SCHEME="Ensu"
-DERIVED_DATA_PATH="$ROOT/build"
-ARCHIVE_PATH="$DERIVED_DATA_PATH/Archive/Ensu.xcarchive"
+ARCHIVE_PATH="$ROOT/build/Archive/Ensu.xcarchive"
ARCHIVE_AFTER_SETUP=0
@@ -113,9 +110,7 @@ print_step "Resolving Swift package dependencies"
cd "$ROOT"
xcodebuild \
-resolvePackageDependencies \
- -project "$PROJECT" \
- -scheme "$SCHEME" \
- -derivedDataPath "$DERIVED_DATA_PATH"
+ -scheme Ensu
)
print_step "Setup complete"
@@ -125,8 +120,7 @@ Local archive prerequisites are ready.
Archive command:
cd "$ROOT"
xcodebuild \\
- -project $PROJECT \\
- -scheme $SCHEME \\
+ -scheme Ensu \\
-configuration Release \\
-sdk iphoneos \\
-destination 'generic/platform=iOS' \\
@@ -144,8 +138,7 @@ if [[ "$ARCHIVE_AFTER_SETUP" == "1" ]]; then
(
cd "$ROOT"
xcodebuild \
- -project "$PROJECT" \
- -scheme "$SCHEME" \
+ -scheme Ensu \
-configuration Release \
-sdk iphoneos \
-destination 'generic/platform=iOS' \