Skip to content

Commit b58b4c4

Browse files
beariceclaude
andcommitted
Consolidate macOS build scripts into build_macos.sh
- Merge build_app_icon.sh and create_dmg.sh functionality into build_macos.sh - Add version updating from Cargo.toml to Info.plist before packaging - Add proper error handling for missing iconutil/sips tools - Remove redundant script files for cleaner build process 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 9fa455e commit b58b4c4

File tree

3 files changed

+51
-82
lines changed

3 files changed

+51
-82
lines changed

build_app_icon.sh

Lines changed: 0 additions & 34 deletions
This file was deleted.

build_macos.sh

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ echo "🍎 Starting macOS build process..."
1414
# Configuration
1515
APP_NAME="RustCat"
1616
BUNDLE_ID="com.bearice.rustcat"
17-
VERSION=$(grep '^version' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
17+
VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
1818

1919
# Build targets
2020
INTEL_TARGET="x86_64-apple-darwin"
@@ -45,7 +45,30 @@ file rust_cat_universal
4545

4646
# Create app icon
4747
echo "🎨 Creating app icon..."
48-
./build_app_icon.sh || echo "⚠️ Could not create app icon, continuing without it"
48+
if command -v iconutil &> /dev/null; then
49+
# Create iconset directory
50+
mkdir -p RustCat.iconset
51+
52+
# Convert ICO to PNG at required sizes using sips (macOS built-in tool)
53+
if command -v sips &> /dev/null; then
54+
sips -s format png -Z 16 assets/appIcon.ico --out RustCat.iconset/icon_16x16.png
55+
sips -s format png -Z 32 assets/appIcon.ico --out RustCat.iconset/icon_32x32.png
56+
sips -s format png -Z 128 assets/appIcon.ico --out RustCat.iconset/icon_128x128.png
57+
sips -s format png -Z 256 assets/appIcon.ico --out RustCat.iconset/icon_256x256.png
58+
sips -s format png -Z 512 assets/appIcon.ico --out RustCat.iconset/icon_512x512.png
59+
else
60+
echo "❌ sips not found - cannot create app icon"
61+
exit 1
62+
fi
63+
64+
# Create the .icns file
65+
iconutil -c icns RustCat.iconset
66+
67+
echo "✅ App icon created: RustCat.icns"
68+
else
69+
echo "❌ iconutil not found - cannot create app icon"
70+
exit 1
71+
fi
4972

5073
# Create app bundle
5174
echo "📱 Creating app bundle..."
@@ -56,16 +79,13 @@ mkdir -p "$APP_BUNDLE/Contents/Resources"
5679
# Copy binary
5780
cp rust_cat_universal "$APP_BUNDLE/Contents/MacOS/rust_cat"
5881

59-
# Copy Info.plist
60-
cp Info.plist "$APP_BUNDLE/Contents/"
82+
# Update and copy Info.plist with current version
83+
echo "📝 Updating Info.plist with version $VERSION..."
84+
sed "s/<string>2\.2\.0<\/string>/<string>$VERSION<\/string>/g" Info.plist > "$APP_BUNDLE/Contents/Info.plist"
6185

62-
# Copy app icon if it exists
63-
if [ -f "RustCat.icns" ]; then
64-
cp RustCat.icns "$APP_BUNDLE/Contents/Resources/AppIcon.icns"
65-
echo "✅ App icon added"
66-
else
67-
echo "⚠️ No app icon found"
68-
fi
86+
# Copy app icon
87+
cp RustCat.icns "$APP_BUNDLE/Contents/Resources/AppIcon.icns"
88+
echo "✅ App icon added"
6989

7090
# Make binary executable
7191
chmod +x "$APP_BUNDLE/Contents/MacOS/rust_cat"
@@ -76,7 +96,26 @@ zip -r "${APP_NAME}-universal.app.zip" "$APP_BUNDLE"
7696

7797
# Create DMG
7898
echo "💿 Creating DMG..."
79-
./create_dmg.sh "$APP_BUNDLE" "${APP_NAME}-universal.dmg"
99+
DMG_NAME="${APP_NAME}-universal.dmg"
100+
101+
# Create a temporary directory for DMG contents
102+
TEMP_DIR=$(mktemp -d)
103+
DMG_DIR="$TEMP_DIR/dmg_contents"
104+
mkdir -p "$DMG_DIR"
105+
106+
# Copy the app bundle to the DMG directory
107+
cp -R "$APP_BUNDLE" "$DMG_DIR/"
108+
109+
# Create a symbolic link to Applications folder for easy installation
110+
ln -s /Applications "$DMG_DIR/Applications"
111+
112+
# Create the DMG
113+
hdiutil create -volname "RustCat" -srcfolder "$DMG_DIR" -ov -format UDZO "$DMG_NAME"
114+
115+
# Clean up temporary directory
116+
rm -rf "$TEMP_DIR"
117+
118+
echo "✅ DMG created: $DMG_NAME"
80119

81120
# Clean up temporary files
82121
echo "🧹 Cleaning up..."

create_dmg.sh

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)