Share receiver for URLs - save, tag and route elsewhere!
1#!/bin/bash
2# Single command to run the iOS app with dev server
3
4set -e
5
6echo "🚀 Starting Peek iOS development..."
7
8# Kill any existing Vite servers
9lsof -ti:1420 | xargs kill -9 2>/dev/null || true
10
11# Start Vite dev server in background
12echo "📦 Starting Vite dev server..."
13npx vite &
14VITE_PID=$!
15
16# Wait for Vite to be ready
17echo "⏳ Waiting for Vite to start..."
18for i in {1..30}; do
19 if lsof -i:1420 2>/dev/null | grep -q LISTEN; then
20 echo "✓ Vite ready on http://localhost:1420"
21 break
22 fi
23 sleep 0.5
24done
25
26# Build Rust library
27echo "🦀 Building Rust library for iOS..."
28cd src-tauri
29cargo build --target aarch64-apple-ios-sim --lib
30mkdir -p gen/apple/Externals/arm64/debug
31cp target/aarch64-apple-ios-sim/debug/libtauri_app_lib.a \
32 gen/apple/Externals/arm64/debug/libapp.a
33cd ..
34echo "✓ Rust library built"
35
36# Build and run in simulator
37echo "📱 Building and deploying to simulator..."
38cd src-tauri/gen/apple
39
40# Find the first available iOS simulator
41SIMULATOR_ID=$(xcrun simctl list devices | grep -m 1 "iPhone.*Booted" | sed -E 's/.*\(([A-F0-9-]+)\).*/\1/')
42if [ -z "$SIMULATOR_ID" ]; then
43 # Boot the first available iPhone simulator
44 SIMULATOR_ID=$(xcrun simctl list devices | grep -m 1 "iPhone" | sed -E 's/.*\(([A-F0-9-]+)\).*/\1/')
45 echo "📱 Booting simulator $SIMULATOR_ID..."
46 xcrun simctl boot "$SIMULATOR_ID" 2>/dev/null || true
47fi
48echo "📱 Using simulator: $SIMULATOR_ID"
49
50# Build and install
51xcodebuild -project tauri-app.xcodeproj \
52 -scheme tauri-app_iOS \
53 -configuration Debug \
54 -destination "id=$SIMULATOR_ID" \
55 -derivedDataPath build \
56 build
57
58# Install the app
59APP_PATH=$(find build/Build/Products/Debug-iphonesimulator -name "*.app" -maxdepth 1)
60xcrun simctl install "$SIMULATOR_ID" "$APP_PATH"
61
62# Launch the app
63BUNDLE_ID="com.dietrich.peek"
64xcrun simctl launch "$SIMULATOR_ID" "$BUNDLE_ID"
65
66echo "✅ App launched successfully!"
67echo "Press Ctrl+C to stop the dev server"
68
69# Wait for Ctrl+C
70trap "kill $VITE_PID 2>/dev/null; echo '🛑 Stopped'; exit" INT TERM
71wait $VITE_PID