-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·135 lines (115 loc) · 3.5 KB
/
build.sh
File metadata and controls
executable file
·135 lines (115 loc) · 3.5 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
# MiddleDrag Build Script
# Builds the app with proper framework linking and code signing
set -e # Exit on error
# Configuration
APP_NAME="MiddleDrag"
BUILD_DIR="build"
BUNDLE_ID="com.middledrag.MiddleDrag"
# Parse arguments
CONFIGURATION="Release"
RUN_AFTER=false
CLEAN_BUILD=false
while [[ $# -gt 0 ]]; do
case $1 in
--clean|-c)
CLEAN_BUILD=true
shift
;;
--debug|-d)
CONFIGURATION="Debug"
shift
;;
--run|-r)
RUN_AFTER=true
shift
;;
--help|-h)
echo "Usage: ./build.sh [options]"
echo ""
echo "Options:"
echo " --clean, -c Clean previous build"
echo " --debug, -d Build debug configuration"
echo " --run, -r Run after building"
echo " --help, -h Show this help"
exit 0
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
echo "🔨 Building MiddleDrag ($CONFIGURATION)..."
# Clean previous build
if [ "$CLEAN_BUILD" = true ]; then
echo "Cleaning previous build..."
rm -rf "$BUILD_DIR"
fi
# Set architecture flags based on configuration
if [ "$CONFIGURATION" = "Release" ]; then
ARCH_FLAGS=(ARCHS="arm64 x86_64" ONLY_ACTIVE_ARCH=NO)
else
ARCH_FLAGS=(ONLY_ACTIVE_ARCH=YES)
fi
# Create build directory
mkdir -p "$BUILD_DIR"
# Build with xcodebuild
echo "Building with Xcode..."
xcodebuild \
-jobs $(sysctl -n hw.ncpu) \
-project "$APP_NAME.xcodeproj" \
-scheme "$APP_NAME" \
-configuration "$CONFIGURATION" \
-derivedDataPath "$BUILD_DIR" \
PRODUCT_BUNDLE_IDENTIFIER="$BUNDLE_ID" \
OTHER_LDFLAGS="-F/System/Library/PrivateFrameworks -framework MultitouchSupport -framework CoreFoundation -framework CoreGraphics" \
FRAMEWORK_SEARCH_PATHS="/System/Library/PrivateFrameworks" \
CODE_SIGN_IDENTITY="-" \
CODE_SIGNING_REQUIRED=NO \
"${ARCH_FLAGS[@]}"
# Find the built app
APP_PATH="$BUILD_DIR/Build/Products/$CONFIGURATION/$APP_NAME.app"
if [ -z "$APP_PATH" ]; then
echo "❌ Build failed: Could not find $APP_NAME.app"
exit 1
fi
# Copy third-party licenses to app bundle
if [ -f "THIRD_PARTY_LICENSES" ]; then
cp "THIRD_PARTY_LICENSES" "$APP_PATH/Contents/Resources/"
echo "📄 Added third-party licenses to bundle"
fi
echo "✅ Build successful!"
echo "📦 App location: $APP_PATH"
# Run if requested
if [ "$RUN_AFTER" = true ]; then
echo ""
echo "🚀 Running $APP_NAME..."
echo "📝 Debug output:"
echo "================"
"$APP_PATH/Contents/MacOS/$APP_NAME"
exit 0
fi
# For release builds, offer to copy to Applications
if [ "$CONFIGURATION" = "Release" ]; then
read -p "Copy to /Applications? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Copying to /Applications..."
rm -rf "/Applications/$APP_NAME.app" 2>/dev/null || true
cp -R "$APP_PATH" "/Applications/"
echo "✅ Copied to /Applications/$APP_NAME.app"
# Set proper permissions
chmod -R 755 "/Applications/$APP_NAME.app"
# Kill existing instance if running
killall "$APP_NAME" 2>/dev/null || true
# Launch the app
read -p "Launch $APP_NAME now? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
open "/Applications/$APP_NAME.app"
echo "🚀 $APP_NAME launched!"
fi
fi
fi
echo "🎉 Done!"