Package your compiled binary into a native macOS Application Bundle.
Package your compiled freqwavecalc_mac binary into a native macOS Application Bundle (.app)
To package your compiled freqwavecalc_mac binary into a native macOS Application Bundle (.app), you need to create a specific folder structure and include an Info.plist metadata file. This bundle allows you to give the app a custom icon, place it in your /Applications directory, and launch it directly from the macOS Dock or Launchpad without a terminal window popping up.Here is the complete script to automate this packaging process.1. Create the App Bundling Script (packmac.sh)Create a new file named packmac.sh in your project’s root folder and paste this code:bash#!/usr/bin/env bash
# Exit immediately if any command fails
set -e
# Ensure we are in the script's directory
cd "$(dirname "$0")"
APP_NAME="WaveCalculator"
BUNDLE_DIR="build/${APP_NAME}.app"
CONTENTS_DIR="${BUNDLE_DIR}/Contents"
MACOS_DIR="${CONTENTS_DIR}/MacOS"
RESOURCES_DIR="${CONTENTS_DIR}/Resources"
echo "============================================="
echo "📦 Packaging Wave Calculator into macOS App Bundle"
echo "============================================="
# 1. Verify that the universal binary exists
if [ ! -f "build/freqwavecalc_mac" ]; then
echo "❌ Error: build/freqwavecalc_mac not found!"
echo "Please run './buildmac.sh' or 'nimble buildmac' first."
exit 1
fi
# 2. Create the clean bundle directory structure
echo "[1/3] Creating folder structure..."
rm -rf "$BUNDLE_DIR"
mkdir -p "$MACOS_DIR"
mkdir -p "$RESOURCES_DIR"
# 3. Copy the binary into the bundle and rename it to match the app title
echo "[2/3] Copying production binary..."
cp "build/freqwavecalc_mac" "${MACOS_DIR}/${APP_NAME}"
# 4. Generate the Info.plist file configuration
echo "[3/3] Generating Info.plist metadata configuration..."
cat <<EOF > "${CONTENTS_DIR}/Info.plist"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://apple.com">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${APP_NAME}</string>
<key>CFBundleIconFile</key>
<string>AppIcon.icns</string>
<key>CFBundleIdentifier</key>
<string>com.mrbean.freqwavecalc</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${APP_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>10.13</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
EOF
echo "============================================="
echo "🎉 Success! App bundle created at: ${BUNDLE_DIR}"
echo "👉 You can now move it to your /Applications folder."
echo "============================================="Make it Executable and Run ItRun these commands in your Mac terminal:bashchmod +x packmac.sh
./packmac.shOnce executed, check your build/ directory. You will find WaveCalculator.app. Double-clicking this bundle in Finder will natively launch your WebUI Wave Calculator app!
Optional: Adding a Custom Application IconRight now.
the Info.plist looks for an icon file named AppIcon.icns. If you want to replace the generic system icon blank sheet with a custom graphic:
- Prepare a transparent square PNG file (e.g., icon.png, ideally 512x512 pixels).
- Open your terminal and use macOS’s built-in tool to convert it to Apple’s native icon format:
mkdir tmp.iconset sips -z 512 512 icon.png --out tmp.iconset/icon_512x512.png iconutil -c icns tmp.iconset -o build/WaveCalculator.app/Contents/Resources/AppIcon.icns rm -rf tmp.iconset