#!/bin/bash # Build Bugger.app for distribution (personal use, ad-hoc signed). # Prerequisites: Config.xcconfig with your FEISHU_APP_ID / FEISHU_APP_SECRET. set -e cd "$(dirname "$0")/.." PROJECT="Bugger.xcodeproj" SCHEME="Bugger" BUILD_DIR="build" APP_NAME="Bugger.app" echo "=== Cleaning ===" xcodebuild -project "$PROJECT" -scheme "$SCHEME" clean 1>/dev/null # Use Config.xcconfig if present XCCONFIG_FLAG="" if [ -f "Config.xcconfig" ]; then XCCONFIG_FLAG="-xcconfig Config.xcconfig" echo "=== Using Config.xcconfig ===" else echo "=== WARNING: Config.xcconfig not found, credentials will be empty ===" fi echo "=== Building Release ===" xcodebuild -project "$PROJECT" -scheme "$SCHEME" \ -configuration Release \ -derivedDataPath "$BUILD_DIR/derived" \ $XCCONFIG_FLAG \ build 2>&1 | grep -E "^.../|error:|BUILD|warning:.*Swift" # Find the built .app APP_PATH=$(find "$BUILD_DIR/derived/Build/Products/Release" -name "*.app" -type d | head -1) if [ -z "$APP_PATH" ]; then echo "ERROR: Could not find built .app" exit 1 fi # Read the marketing version from the built app so the DMG name stays in # sync with MARKETING_VERSION / CFBundleShortVersionString automatically. VERSION=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$APP_PATH/Contents/Info.plist") if [ -z "$VERSION" ]; then echo "ERROR: Could not read version from $APP_PATH/Contents/Info.plist" exit 1 fi echo "" echo "=== Built: $APP_PATH (v$VERSION) ===" echo "" # Copy to build root rm -rf "$BUILD_DIR/$APP_NAME" cp -R "$APP_PATH" "$BUILD_DIR/$APP_NAME" # Create DMG echo "=== Creating DMG ===" mkdir -p "$BUILD_DIR/dmg" rm -rf "$BUILD_DIR/dmg/"* cp -R "$BUILD_DIR/$APP_NAME" "$BUILD_DIR/dmg/" ln -sf /Applications "$BUILD_DIR/dmg/Applications" 2>/dev/null || true DMG="$BUILD_DIR/Bugger-${VERSION}.dmg" rm -f "$DMG" hdiutil create -volname Bugger -srcfolder "$BUILD_DIR/dmg" \ -ov -format UDZO "$DMG" 1>/dev/null echo "" echo "=== Done ===" echo " App: $PWD/$BUILD_DIR/$APP_NAME" echo " DMG: $PWD/$DMG" echo "" echo "To install:" echo " cp -R $BUILD_DIR/$APP_NAME /Applications/" echo "" echo "On first launch, right-click the app → Open (Gatekeeper bypass)."