|
1
|
#!/usr/bin/env bash |
|
2
|
# ============================================================================= |
|
3
|
# apple/bootstrap.sh |
|
4
|
# |
|
5
|
# Bidirectional sync between src-tauri/apple/ (source of truth, git-tracked) |
|
6
|
# and gen/apple/ (Tauri's blast radius, git-ignored). |
|
7
|
# |
|
8
|
# Usage: |
|
9
|
# ./apple/bootstrap.sh # same as 'push' |
|
10
|
# ./apple/bootstrap.sh push # apple/ → gen/apple/ (deploy overlay) |
|
11
|
# ./apple/bootstrap.sh pull # gen/apple/ → apple/ (save your work) |
|
12
|
# |
|
13
|
# Workflow: |
|
14
|
# First time / after cargo tauri ios init: |
|
15
|
# ./apple/bootstrap.sh push |
|
16
|
# |
|
17
|
# After editing in Xcode (files live in gen/apple/): |
|
18
|
# ./apple/bootstrap.sh pull |
|
19
|
# |
|
20
|
# The apple/ directory lives outside the Tauri blast radius (gen/apple/) |
|
21
|
# so it survives rm -rf gen/apple && cargo tauri ios init. |
|
22
|
# ============================================================================= |
|
23
|
set -euo pipefail |
|
24
|
|
|
25
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" |
|
26
|
SRC_TAURI="$(cd "$SCRIPT_DIR/.." && pwd)" |
|
27
|
APPLE="$SRC_TAURI/gen/apple" |
|
28
|
|
|
29
|
# Files and directories we own (not generated by Tauri) |
|
30
|
OVERLAY_FILES=( |
|
31
|
Project.swift |
|
32
|
Tuist.swift |
|
33
|
mise.toml |
|
34
|
README.md |
|
35
|
) |
|
36
|
OVERLAY_DIRS=( |
|
37
|
tauri-app_tvOS |
|
38
|
tauri-app_watchOS |
|
39
|
tauri-app_visionOS |
|
40
|
) |
|
41
|
|
|
42
|
# --------------------------------------------------------------------------- |
|
43
|
push() { |
|
44
|
if [ ! -d "$APPLE" ]; then |
|
45
|
echo "❌ $APPLE does not exist." |
|
46
|
echo " Run 'cargo tauri ios init' first, then re-run this script." |
|
47
|
exit 1 |
|
48
|
fi |
|
49
|
|
|
50
|
echo "▶ push: apple/ → gen/apple/ …" |
|
51
|
|
|
52
|
for f in "${OVERLAY_FILES[@]}"; do |
|
53
|
cp "$SCRIPT_DIR/$f" "$APPLE/$f" |
|
54
|
done |
|
55
|
|
|
56
|
# .gitignore is stored as apple.gitignore to stay visible in editors |
|
57
|
cp "$SCRIPT_DIR/apple.gitignore" "$APPLE/.gitignore" |
|
58
|
|
|
59
|
for d in "${OVERLAY_DIRS[@]}"; do |
|
60
|
mkdir -p "$APPLE/$d" |
|
61
|
cp -R "$SCRIPT_DIR/$d/." "$APPLE/$d/" |
|
62
|
done |
|
63
|
|
|
64
|
echo "✅ Apple platform overlay applied." |
|
65
|
echo "" |
|
66
|
echo " Next steps:" |
|
67
|
echo " mise install # install pinned tuist" |
|
68
|
echo " tuist generate --no-open # (re)generate Xcode project" |
|
69
|
echo "" |
|
70
|
} |
|
71
|
|
|
72
|
# --------------------------------------------------------------------------- |
|
73
|
pull() { |
|
74
|
if [ ! -d "$APPLE" ]; then |
|
75
|
echo "❌ $APPLE does not exist. Nothing to pull." |
|
76
|
exit 1 |
|
77
|
fi |
|
78
|
|
|
79
|
echo "▶ pull: gen/apple/ → apple/ …" |
|
80
|
|
|
81
|
for f in "${OVERLAY_FILES[@]}"; do |
|
82
|
if [ -f "$APPLE/$f" ]; then |
|
83
|
cp "$APPLE/$f" "$SCRIPT_DIR/$f" |
|
84
|
fi |
|
85
|
done |
|
86
|
|
|
87
|
# Pull .gitignore back as apple.gitignore |
|
88
|
if [ -f "$APPLE/.gitignore" ]; then |
|
89
|
cp "$APPLE/.gitignore" "$SCRIPT_DIR/apple.gitignore" |
|
90
|
fi |
|
91
|
|
|
92
|
for d in "${OVERLAY_DIRS[@]}"; do |
|
93
|
if [ -d "$APPLE/$d" ]; then |
|
94
|
mkdir -p "$SCRIPT_DIR/$d" |
|
95
|
cp -R "$APPLE/$d/." "$SCRIPT_DIR/$d/" |
|
96
|
fi |
|
97
|
done |
|
98
|
|
|
99
|
echo "✅ Changes pulled back into apple/." |
|
100
|
echo " Don't forget to commit." |
|
101
|
echo "" |
|
102
|
} |
|
103
|
|
|
104
|
# --------------------------------------------------------------------------- |
|
105
|
case "${1:-push}" in |
|
106
|
push) push ;; |
|
107
|
pull) pull ;; |
|
108
|
*) |
|
109
|
echo "Usage: $0 [push|pull]" |
|
110
|
echo "" |
|
111
|
echo " push — copy apple/ → gen/apple/ (default)" |
|
112
|
echo " pull — copy gen/apple/ → apple/ (save Xcode edits)" |
|
113
|
exit 1 |
|
114
|
;; |
|
115
|
esac |