-
-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathassemble.sh
More file actions
executable file
·91 lines (72 loc) · 2.91 KB
/
assemble.sh
File metadata and controls
executable file
·91 lines (72 loc) · 2.91 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
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
set -e
shopt -s extglob
MODE=$1
if [[ $MODE != "release" && $MODE != "debug" ]]; then
echo "❌ Invalid mode. Must be 'release' or 'debug'"
exit 1
fi
if [[ ! -e "Package.swift" || ! -e "Calendr.xcodeproj" ]]; then
echo "❌ This script must be run from the project root directory"
exit 1
fi
# Build the Binary
swift build -c $MODE
# Configuration
CONFIG_DIR="Calendr/Config"
BUILD_DIR="$(swift build -c $MODE --show-bin-path)"
APP_BUNDLE=".build/Calendr.app"
CONTENTS="$APP_BUNDLE/Contents"
# Clean up and Create Folders
rm -rf "$APP_BUNDLE"
mkdir -p "$CONTENTS/MacOS"
mkdir -p "$CONTENTS/Resources"
mkdir -p "$CONTENTS/Frameworks"
# Move the Binary
cp "$BUILD_DIR/Calendr" "$CONTENTS/MacOS/"
# Move your existing Info.plist
cp "$CONFIG_DIR/Info.plist" "$CONTENTS/Info.plist"
# Move Frameworks (like Sentry)
cp -R "$BUILD_DIR"/*.framework "$CONTENTS/Frameworks/"
# Unpack main bundle resources
cp -R "$BUILD_DIR"/Calendr_Calendr.bundle/!(Images.xcassets|Info.plist) "$CONTENTS/Resources/"
# Move all SPM-generated Bundles
cp -R "$BUILD_DIR"/!(Calendr_Calendr).bundle "$CONTENTS/Resources/"
# --- The "Xcode" Variables --- #
PBXPROJ="Calendr.xcodeproj/project.pbxproj"
get_setting() {
# Search the file, but ignore any lines that contain 'Test'
grep "$1 =" "$PBXPROJ" | grep -v "Tests" | head -1 | cut -d'=' -f2 | tr -d '"; '
}
# Extract the values
BUNDLE_ID=$(get_setting "PRODUCT_BUNDLE_IDENTIFIER")
VERSION=$(get_setting "MARKETING_VERSION")
BUILD_NUMBER=$(get_setting "CURRENT_PROJECT_VERSION")
MIN_OS=$(get_setting "MACOSX_DEPLOYMENT_TARGET")
# Path to your packaged plist
PLIST="$CONTENTS/Info.plist"
# Inject using plutil (which is included in Command Line Tools)
echo -e "\n💉 Injecting extracted values: ID=$BUNDLE_ID, Version=$VERSION, Build=$BUILD_NUMBER\n"
plutil -replace CFBundleIdentifier -string "$BUNDLE_ID" "$PLIST"
plutil -replace CFBundleShortVersionString -string "$VERSION" "$PLIST"
plutil -replace CFBundleVersion -string "$BUILD_NUMBER" "$PLIST"
plutil -replace LSMinimumSystemVersion -string "$MIN_OS" "$PLIST"
plutil -replace CFBundleExecutable -string "Calendr" "$PLIST"
plutil -replace CFBundleName -string "Calendr" "$PLIST"
plutil -replace CFBundlePackageType -string "APPL" "$PLIST"
plutil -replace CFBundleIconFile -string "AppIcon" "$PLIST"
plutil -replace CFBundleIconName -string "AppIcon" "$PLIST"
# Compile Assets (only if Xcode is installed)
if xcrun actool --version &>/dev/null; then
xcrun actool "$BUILD_DIR/Calendr_Calendr.bundle/Images.xcassets" \
--compile "$CONTENTS/Resources" \
--platform macosx \
--minimum-deployment-target "$MIN_OS" \
--app-icon AppIcon \
--output-partial-info-plist ".build/asset-info.plist" \
--output-format human-readable-text \
> /dev/null
else
echo -e "⚠️ actool not available (full Xcode required), skipping assets compilation.\n"
fi
echo "✅ $APP_BUNDLE assembled successfully!"