-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflatten_storekit.sh
More file actions
executable file
·79 lines (63 loc) · 2.37 KB
/
flatten_storekit.sh
File metadata and controls
executable file
·79 lines (63 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
set -e
# Paths
SWIFT_SRC="$HOME/Visual Studio Projects/Maui.InAppBilling/plugin.howitzergames.storekit2/swift/StoreKit2-swift/StoreKit2.xcframework"
EXTERNALS_DIR="$HOME/Visual Studio Projects/Maui.InAppBilling/plugin.howitzergames.storekit2/externals"
DEST="$EXTERNALS_DIR/StoreKit2.xcframework"
echo "📦 Copying StoreKit2.xcframework to externals..."
rm -rf "$DEST"
cp -R "$SWIFT_SRC" "$DEST"
echo "✅ Copy complete"
echo
echo "🔍 Processing xcframework slices..."
# Iterate through top-level xcframework slices
for SLICE in "$DEST"/*; do
SLICE_NAME=$(basename "$SLICE")
# Skip non-directories
[ -d "$SLICE" ] || continue
# Skip Mac Catalyst entirely
if [[ "$SLICE_NAME" == *maccatalyst* ]]; then
echo "⏭️ Skipping Mac Catalyst slice: $SLICE_NAME"
continue
fi
# Only flatten iOS + Simulator
if [[ "$SLICE_NAME" == ios-* || "$SLICE_NAME" == *simulator* ]]; then
echo "🔧 Flattening symlinks in slice: $SLICE_NAME"
else
echo "⏭️ Skipping unknown slice: $SLICE_NAME"
continue
fi
# --- Flatten Versions/Current first ---
find "$SLICE" -type d -name "Versions" | while read -r VERSIONS_DIR; do
CURRENT_LINK="$VERSIONS_DIR/Current"
if [ -L "$CURRENT_LINK" ]; then
TARGET_DIR=$(readlink "$CURRENT_LINK")
ABS_TARGET_DIR=$(realpath "$VERSIONS_DIR/$TARGET_DIR")
echo " ↳ Replacing Versions/Current symlink"
rm "$CURRENT_LINK"
cp -R "$ABS_TARGET_DIR" "$VERSIONS_DIR/Current"
fi
done
# --- Flatten remaining symlinks ---
find "$SLICE" -type l | while read -r SYMLINK; do
TARGET=$(readlink "$SYMLINK")
SYMLINK_DIR=$(dirname "$SYMLINK")
ABS_TARGET=$(realpath "$SYMLINK_DIR/$TARGET")
if [ ! -e "$ABS_TARGET" ]; then
echo " ⚠️ Missing target for $SYMLINK"
continue
fi
TEMP_PATH="${SYMLINK}.real"
cp -R "$ABS_TARGET" "$TEMP_PATH"
rm "$SYMLINK"
mv "$TEMP_PATH" "$SYMLINK"
echo " ✔ Flattened: $SYMLINK"
done
# --- Remove Versions folders (safe for iOS only) ---
find "$SLICE" -type d -name "Versions" | while read -r VERSIONS_DIR; do
echo " 🧹 Removing Versions folder"
rm -rf "$VERSIONS_DIR"
done
done
echo
echo "✅ Flattening complete (iOS + Simulator only)"