1
0
Fork 0
mirror of synced 2024-05-03 12:03:22 +12:00

Refine macOS app bundle creation process

Simplified the macOS app bundling instructions in `Installation.md` and streamlined the app bundle script.
This commit is contained in:
Petr Korolev 2024-03-24 16:45:48 +07:00
parent 17d1fc25f2
commit a0e17d89a0
2 changed files with 19 additions and 48 deletions

View file

@ -79,25 +79,12 @@ Sadly this doesn't work for all users, so feel free to update this part of docum
To generate an app bundle on macOS, you can use the provided script `./misc/create_app_bundle.sh`. This script will create an `.app` bundle with the necessary structure and copy the executable and icon files into the correct locations.
Before running the script, make sure you have the `librsvg` library installed, which is used to convert SVG icons to PNG format. You can install it using Homebrew:
1. Install `librsvg` with Homebrew: `brew install librsvg`
2. Run the script: `./misc/create_app_bundle.sh`
3. The `.app` bundle will be in `./target/release`
4. Move the bundle to Applications: `mv ./target/release/Czkawka.app /Applications`
```shellscript
brew install librsvg
```
Then, you can run the script with the following command:
```shellscript
./misc/create_app_bundle.sh
```
After running the script, you will find the generated `.app` bundle in the `./target/release` directory.
You can move this bundle to your Applications folder to install the app:
```shellscript
mv ./target/release/Czkawka.app /Applications
```
Now, you should be able to launch Czkawka from your Applications folder or via Spotlight search.
Now, you can launch Czkawka from your Applications folder or via Spotlight search.
### Windows
By default, all needed libraries are bundled with the app except libheif library which allows to scan/use heif files, inside `windows_czkawka_gui.zip`, but if you compile the app or just move `czkawka_gui.exe`, then you will need to install the `GTK 4`

View file

@ -1,54 +1,38 @@
#!/bin/bash
# Define bundle ID
# Define bundle ID and paths
BUNDLE_ID="com.github.qarmin.czkawka"
# Get the directory of the current script (works even if the script is called from another location)
DIR="$(dirname "$0")"
PARENT_DIR="$(dirname "$DIR")"
BUNDLE_NAME="Czkawka.app"
BUNDLE_PATH="$PARENT_DIR/target/release/$BUNDLE_NAME"
BINARY_NAME="czkawka_gui"
# Extract version from Cargo.toml
VERSION=$(grep '^version = ' "$PARENT_DIR/$BINARY_NAME/Cargo.toml" | head -n 1 | cut -d '"' -f 2)
# Step 1: Build the project
cargo build --release --manifest-path="$DIR/../Cargo.toml" --bin $BINARY_NAME
# Step 2: Create the application bundle structure
mkdir -p "$BUNDLE_PATH/Contents/MacOS"
mkdir -p "$BUNDLE_PATH/Contents/Resources"
# Step 3: Copy the binary
cp "$PARENT_DIR/target/release/$BINARY_NAME" "$BUNDLE_PATH/Contents/MacOS/"
# Step 4: Generate the icon from SVG and copy it to the bundle
SVG_PATH="$PARENT_DIR/data/icons/${BUNDLE_ID}.svg"
ICONSET_DIR="${PARENT_DIR}/data/icons/${BUNDLE_ID}.iconset"
# Create iconset directory
mkdir -p "$ICONSET_DIR"
# Generate icon sizes and populate the iconset
ICON_SIZES="16 32 64 128 256 512"
SRC_ICON="$SVG_PATH"
# Build the project
cargo build --release --manifest-path="$DIR/../Cargo.toml" --bin $BINARY_NAME
# Create the application bundle structure and copy the binary
mkdir -p "$BUNDLE_PATH/Contents/MacOS" "$BUNDLE_PATH/Contents/Resources"
cp "$PARENT_DIR/target/release/$BINARY_NAME" "$BUNDLE_PATH/Contents/MacOS/"
# Create iconset directory and generate icon sizes
mkdir -p "$ICONSET_DIR"
for SIZE in $ICON_SIZES; do
rsvg-convert -w $SIZE -h $SIZE $SRC_ICON -o "${ICONSET_DIR}/icon_${SIZE}x${SIZE}.png"
if [ $SIZE -ne 512 ]; then
SIZE_2X=$((SIZE*2))
rsvg-convert -w $SIZE_2X -h $SIZE_2X $SRC_ICON -o "${ICONSET_DIR}/icon_${SIZE}x${SIZE}@2x.png"
fi
[ $SIZE -ne 512 ] && rsvg-convert -w $((SIZE*2)) -h $((SIZE*2)) $SRC_ICON -o "${ICONSET_DIR}/icon_${SIZE}x${SIZE}@2x.png"
done
# Convert the iconset to an icns file
# Convert the iconset to an icns file and clean up the iconset directory
iconutil -c icns "$ICONSET_DIR" -o "$BUNDLE_PATH/Contents/Resources/${BUNDLE_ID}.icns"
# Clean up the iconset directory
rm -rf "$ICONSET_DIR"
# Step 5: Create the Info.plist file
# Create the Info.plist file
cat <<EOF >"$BUNDLE_PATH/Contents/Info.plist"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@ -70,4 +54,4 @@ cat <<EOF >"$BUNDLE_PATH/Contents/Info.plist"
</plist>
EOF
echo "Application bundle created at: $BUNDLE_PATH"
echo "Application bundle created at: $BUNDLE_PATH"