-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·68 lines (56 loc) · 1.75 KB
/
build.sh
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
#!/bin/bash
echo "🚀 Starting build process..."
# Set variables
APP_NAME="BTCWatcher"
MAIN_SWIFT="main.swift"
APP_BUNDLE="$APP_NAME.app"
APP_EXECUTABLE="$APP_BUNDLE/Contents/MacOS/$APP_NAME"
ZIP_NAME="$APP_NAME.app.zip"
# Create necessary directories if they don't exist
echo "📁 Creating app bundle structure..."
mkdir -p "$APP_BUNDLE/Contents/MacOS"
mkdir -p "$APP_BUNDLE/Contents/Resources"
# Compile the Swift code
echo "🔨 Compiling Swift code..."
swiftc -o "$APP_EXECUTABLE" "$MAIN_SWIFT"
if [ $? -ne 0 ]; then
echo "❌ Compilation failed!"
exit 1
fi
# Set executable permissions
echo "🔒 Setting permissions..."
chmod +x "$APP_EXECUTABLE"
# Copy Info.plist if it exists
if [ -f "Info.plist" ]; then
echo "📄 Copying Info.plist..."
cp "Info.plist" "$APP_BUNDLE/Contents/"
fi
# Copy resources if they exist
if [ -d "Resources" ]; then
echo "🎨 Copying resources..."
cp -r Resources/* "$APP_BUNDLE/Contents/Resources/"
fi
# Remove extended attributes
echo "🧹 Removing extended attributes..."
xattr -cr "$APP_BUNDLE"
# Sign the application
echo "📝 Signing application..."
codesign --force --deep --sign - "$APP_BUNDLE"
# Create zip archive using ditto (preserves permissions and attributes)
echo "📦 Creating zip archive..."
ditto -c -k --keepParent "$APP_BUNDLE" "$ZIP_NAME"
if [ $? -eq 0 ]; then
echo "✅ Build complete!"
echo "📝 To run the app:"
echo "1. Double click $APP_BUNDLE"
echo " or"
echo "2. Run: open $APP_BUNDLE"
echo ""
echo "If you see 'app is damaged' message:"
echo "1. Right-click the app and select 'Open'"
echo "2. Click 'Open' in the security dialog"
echo "3. The app will be saved as an exception"
else
echo "❌ Failed to create zip archive!"
exit 1
fi