Files
tether/core/build-ios.sh
Patrick Ecord 2c375632a5 core: shared Rust sync engine (tethercore) + wire into iOS via UniFFI
Introduce core/ — a Rust crate owning the wire protocol (Message codec,
SSE client, reconnect/backoff, send) behind a 4-method seam exported via
UniFFI: Engine::new / start(handler) / send / stop. This is the single
sync engine meant to back all clients; desktop links it directly, iOS
binds an .xcframework, Android will bind an .aar. RTC mesh + the signal
envelope are deliberately out of scope for v1 (SSE-only).

Verified end-to-end against the live server: examples/roundtrip.rs has a
subscriber engine receive a message published by a sender engine.

iOS now links it: TetherStore drops TetherKit's TetherClient/SSEClient/
Message and drives tethercore.Engine instead (RoomIdentity still from
TetherKit via selective import to avoid the Message name clash). The app
builds and links the Rust staticlib for device.

Artifacts (xcframework, Swift bindings) are generated by core/build-ios.sh
and git-ignored; commit source + script, not the ~80MB static libs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-20 18:44:58 -05:00

39 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Builds the tethercore Rust engine for iOS and refreshes the artifacts the
# Xcode app consumes: the Swift bindings + the TetherCore.xcframework.
# These outputs are git-ignored (binaries) / regenerated — run this after any
# change to core/src, then build the app in Xcode.
set -euo pipefail
cd "$(dirname "$0")"
APP_DIR="../ios/TetherApp"
DEVICE=aarch64-apple-ios
SIM=aarch64-apple-ios-sim
echo "▸ building static libs ($DEVICE, $SIM)…"
rustup target add "$DEVICE" "$SIM" >/dev/null 2>&1 || true
cargo build --release --target "$DEVICE" --lib
cargo build --release --target "$SIM" --lib
echo "▸ generating Swift bindings…"
cargo build --release --lib # host dylib for library-mode bindgen
cargo run --release --bin uniffi-bindgen -- \
generate --library "target/release/libtethercore.dylib" \
--language swift --out-dir bindings/swift
echo "▸ assembling TetherCore.xcframework…"
rm -rf build-xcframework && mkdir -p build-xcframework/headers
cp bindings/swift/tethercoreFFI.h build-xcframework/headers/
cp bindings/swift/tethercoreFFI.modulemap build-xcframework/headers/module.modulemap
rm -rf "$APP_DIR/Vendor/TetherCore.xcframework"
mkdir -p "$APP_DIR/Vendor"
xcodebuild -create-xcframework \
-library "target/$DEVICE/release/libtethercore.a" -headers build-xcframework/headers \
-library "target/$SIM/release/libtethercore.a" -headers build-xcframework/headers \
-output "$APP_DIR/Vendor/TetherCore.xcframework"
echo "▸ refreshing Swift wrapper in app…"
cp bindings/swift/tethercore.swift "$APP_DIR/Sources/tethercore.swift"
echo "✅ done — open $APP_DIR and build."