-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·89 lines (71 loc) · 2.74 KB
/
build.sh
File metadata and controls
executable file
·89 lines (71 loc) · 2.74 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
#!/bin/bash
set -euo pipefail
APP_NAME="GetBackMyWindows"
BUILD_DIR="./Build"
APP_BUNDLE="$BUILD_DIR/$APP_NAME.app"
CERT_NAME="GetBackMyWindowsCert"
DEPLOY_TARGET="15.0"
echo "🚧 Building $APP_NAME (macOS $DEPLOY_TARGET+, universal: arm64+x86_64)..."
if ! security find-identity -v -p codesigning | grep -q "$CERT_NAME"; then
echo "❌ ERROR: Code Signing Certificate '$CERT_NAME' not found!"
echo " Please create a self-signed code signing certificate named '$CERT_NAME' in Keychain Access."
exit 1
fi
SRC_DIR="$(pwd)"
TEMP_BUILD_DIR=$(mktemp -d /tmp/GBMW_Build_XXXX)
echo "🏗️ Building in temporary directory: $TEMP_BUILD_DIR"
TEMP_APP_BUNDLE="$TEMP_BUILD_DIR/$APP_NAME.app"
TEMP_CONTENTS_DIR="$TEMP_APP_BUNDLE/Contents"
TEMP_MACOS_DIR="$TEMP_CONTENTS_DIR/MacOS"
TEMP_RESOURCES_DIR="$TEMP_CONTENTS_DIR/Resources"
TEMP_BIN_ARM64="$TEMP_BUILD_DIR/$APP_NAME.arm64"
TEMP_BIN_X64="$TEMP_BUILD_DIR/$APP_NAME.x86_64"
mkdir -p "$TEMP_MACOS_DIR" "$TEMP_RESOURCES_DIR"
echo "🧱 Compiling arm64 target..."
swiftc "$SRC_DIR/main.swift" "$SRC_DIR/SettingsUI.swift" \
-target "arm64-apple-macos$DEPLOY_TARGET" \
-o "$TEMP_BIN_ARM64" \
-framework Cocoa -framework Carbon
echo "🧱 Compiling x86_64 target..."
swiftc "$SRC_DIR/main.swift" "$SRC_DIR/SettingsUI.swift" \
-target "x86_64-apple-macos$DEPLOY_TARGET" \
-o "$TEMP_BIN_X64" \
-framework Cocoa -framework Carbon
echo "🧩 Creating universal binary..."
lipo -create "$TEMP_BIN_ARM64" "$TEMP_BIN_X64" -output "$TEMP_MACOS_DIR/$APP_NAME"
if [ -f "$SRC_DIR/Info.plist" ]; then
cp -X "$SRC_DIR/Info.plist" "$TEMP_CONTENTS_DIR/Info.plist"
else
echo "❌ Info.plist not found!"
rm -rf "$TEMP_BUILD_DIR"
exit 1
fi
if [ -f "$SRC_DIR/GetBackMyWindows.icns" ]; then
cp -X "$SRC_DIR/GetBackMyWindows.icns" "$TEMP_RESOURCES_DIR/"
else
echo "❌ Icon file GetBackMyWindows.icns not found!"
rm -rf "$TEMP_BUILD_DIR"
exit 1
fi
echo "🧹 Ensuring clean attributes..."
xattr -rc "$TEMP_APP_BUNDLE"
echo "🔏 Signing with identity: $CERT_NAME"
codesign --sign "$CERT_NAME" \
--entitlements "$SRC_DIR/GetBackMyWindows.entitlements" \
--identifier "com.user.GetBackMyWindows" \
--verbose \
--force \
"$TEMP_APP_BUNDLE"
echo "🔍 Verifying Signature..."
codesign -v --strict --deep --verbose=2 "$TEMP_APP_BUNDLE"
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"
mv "$TEMP_APP_BUNDLE" "$BUILD_DIR/"
rm -rf "$TEMP_BUILD_DIR"
echo "✅ Build Successful!"
echo "📂 App located at: $APP_BUNDLE"
ZIP_PATH="$BUILD_DIR/$APP_NAME.app.zip"
echo "📦 Zipping for Release..."
ditto -c -k --norsrc --keepParent "$APP_BUNDLE" "$ZIP_PATH"
echo "✅ Build & Package Successful!"
echo "👉 Release File: $ZIP_PATH (Upload this to GitHub)"